ImmutableListTest.cs 1.5 KB

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