A stealth-based 2D platformer where you don't have to kill anyone unless you want to. https://www.semicolin.games
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.

55 lines
1.5 KiB

  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System;
  3. namespace SemiColinGames.Tests {
  4. [TestClass]
  5. public class HistoryTests {
  6. public static int[] ToArray(History<int> history) {
  7. int[] result = new int[history.Length];
  8. for (int i = 0; i < history.Length; i++) {
  9. result[i] = history[i];
  10. }
  11. return result;
  12. }
  13. [TestMethod]
  14. public void TestLength() {
  15. var h = new History<int>(3);
  16. Assert.AreEqual(3, h.Length);
  17. }
  18. [TestMethod]
  19. public void TestGetFromEmpty() {
  20. var ints = new History<int>(3);
  21. Assert.AreEqual(0, ints[0]);
  22. Assert.AreEqual(0, ints[1]);
  23. Assert.AreEqual(0, ints[2]);
  24. var objects = new History<Object>(1);
  25. Assert.AreEqual(null, objects[0]);
  26. }
  27. [TestMethod]
  28. public void TestAdds() {
  29. var h = new History<int>(3);
  30. Assert.AreEqual("0 0 0", String.Join(" ", ToArray(h)));
  31. h.Add(2);
  32. Assert.AreEqual("2 0 0", String.Join(" ", ToArray(h)));
  33. h.Add(3);
  34. h.Add(5);
  35. Assert.AreEqual("5 3 2", String.Join(" ", ToArray(h)));
  36. h.Add(7);
  37. Assert.AreEqual("7 5 3", String.Join(" ", ToArray(h)));
  38. h.Add(11);
  39. h.Add(13);
  40. Assert.AreEqual("13 11 7", String.Join(" ", ToArray(h)));
  41. }
  42. [TestMethod]
  43. public void TestThrowsExceptions() {
  44. var h = new History<int>(3);
  45. Assert.ThrowsException<IndexOutOfRangeException>(() => h[-1]);
  46. Assert.ThrowsException<IndexOutOfRangeException>(() => h[3]);
  47. }
  48. }
  49. }