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.

48 lines
1.3 KiB

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