示例#1
0
        public void Should_serialize_and_deserialize()
        {
            var sut = ReadonlyList.Create(1, 2, 3);

            var serialized = sut.SerializeAndDeserialize();

            Assert.Equal(sut, serialized);
        }
示例#2
0
        public void Should_make_correct_equal_comparisons()
        {
            var list1a = ReadonlyList.Create(1);
            var list1b = ReadonlyList.Create(1);

            var listOtherValue = ReadonlyList.Create(2);
            var listOtherSize  = ReadonlyList.Create(1, 2);

            Assert.Equal(list1a, list1b);
            Assert.Equal(list1a.GetHashCode(), list1b.GetHashCode());
            Assert.True(list1a.Equals((object)list1b));

            Assert.NotEqual(list1a, listOtherValue);
            Assert.NotEqual(list1a.GetHashCode(), listOtherValue.GetHashCode());
            Assert.False(list1a.Equals((object)listOtherValue));

            Assert.NotEqual(list1a, listOtherSize);
            Assert.NotEqual(list1a.GetHashCode(), listOtherSize.GetHashCode());
            Assert.False(list1a.Equals((object)listOtherSize));
        }
示例#3
0
 public virtual bool Equals(ReadonlyList <T>?other)
 {
     return(this.EqualsList(other));
 }
示例#4
0
        public void Should_return_empty_instance_for_empty_enumerable()
        {
            var result = Enumerable.Empty <int>().ToReadonlyList();

            Assert.Same(ReadonlyList.Empty <int>(), result);
        }
示例#5
0
        public void Should_return_empty_instance_for_null_array()
        {
            var result = ReadonlyList.Create((int[]?)null);

            Assert.Same(ReadonlyList.Empty <int>(), result);
        }