ImmutableListTest.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using System.Linq;
  3. using System.Reactive;
  4. namespace ReactiveTests.Tests
  5. {
  6. #if !SIGNED
  7. [TestClass]
  8. public class ImmutableListTest
  9. {
  10. [TestMethod]
  11. public void ImmutableList_Basics()
  12. {
  13. var list = new ImmutableList<int>();
  14. Assert.IsTrue(list.Data.SequenceEqual(new int[] { }));
  15. list = list.Add(42);
  16. Assert.IsTrue(list.Data.SequenceEqual(new int[] { 42 }));
  17. list = list.Remove(42);
  18. Assert.IsTrue(list.Data.SequenceEqual(new int[] { }));
  19. list = list.Remove(42);
  20. Assert.IsTrue(list.Data.SequenceEqual(new int[] { }));
  21. list = list.Add(43);
  22. list = list.Add(44);
  23. list = list.Add(43);
  24. Assert.IsTrue(list.Data.SequenceEqual(new int[] { 43, 44, 43 }));
  25. list = list.Remove(43);
  26. Assert.IsTrue(list.Data.SequenceEqual(new int[] { 44, 43 }));
  27. list = list.Remove(43);
  28. Assert.IsTrue(list.Data.SequenceEqual(new int[] { 44 }));
  29. list = list.Remove(44);
  30. Assert.IsTrue(list.Data.SequenceEqual(new int[] { }));
  31. }
  32. [TestMethod]
  33. public void ImmutableList_Nulls()
  34. {
  35. var list = new ImmutableList<string>();
  36. Assert.IsTrue(list.Data.SequenceEqual(new string[] { }));
  37. list = list.Add(null);
  38. Assert.IsTrue(list.Data.SequenceEqual(new string[] { null }));
  39. list = list.Remove(null);
  40. Assert.IsTrue(list.Data.SequenceEqual(new string[] { }));
  41. }
  42. }
  43. #endif
  44. }