You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using Microsoft.VisualStudio.TestTools.UnitTesting; using System;
namespace SemiColinGames.Tests { [TestClass] public class HistoryTests { public static int[] ToArray(History<int> history) { int[] result = new int[history.Length]; for (int i = 0; i < history.Length; i++) { result[i] = history[i]; } return result; }
[TestMethod] public void TestLength() { var h = new History<int>(3); Assert.AreEqual(3, h.Length); }
[TestMethod] public void TestGetFromEmpty() { var ints = new History<int>(3); Assert.AreEqual(0, ints[0]); Assert.AreEqual(0, ints[1]); Assert.AreEqual(0, ints[2]);
var objects = new History<Object>(1); Assert.AreEqual(null, objects[0]); }
[TestMethod] public void TestAdds() { var h = new History<int>(3); Assert.AreEqual("0 0 0", String.Join(" ", ToArray(h))); h.Add(2); Assert.AreEqual("2 0 0", String.Join(" ", ToArray(h))); h.Add(3); h.Add(5); Assert.AreEqual("5 3 2", String.Join(" ", ToArray(h))); h.Add(7); Assert.AreEqual("7 5 3", String.Join(" ", ToArray(h))); h.Add(11); h.Add(13); Assert.AreEqual("13 11 7", String.Join(" ", ToArray(h))); }
[TestMethod] public void TestThrowsExceptions() { var h = new History<int>(3); Assert.ThrowsException<IndexOutOfRangeException>(() => h[-1]); Assert.ThrowsException<IndexOutOfRangeException>(() => h[3]); } } }
|