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.4 KiB

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