Ejemplo n.º 1
0
        public void TestEqualityRules()
        {
            ImmutableArrayList first  = new ImmutableArrayList(AsArray("1", "2", "3"));
            ImmutableArrayList second = new ImmutableArrayList(AsArray("1", "2", "3"));

            // x.Equals(null) == false
            Assert.IsFalse(first.Equals(null));
            // x.Equals(x) == true
            Assert.IsTrue(first.Equals(first));


            // x.Equals(y) == y.Equals(x)
            Assert.IsTrue(first.Equals(second));
            Assert.AreEqual(first.Equals(second), second.Equals(first));
        }
Ejemplo n.º 2
0
        public void TestEqualityBehaviorWithList()
        {
            ImmutableArrayList iaList   = new ImmutableArrayList(AsArray("1", "2", "3"));
            ArrayList          arrList1 = new ArrayList(AsArray("1", "2", "3"));
            ArrayList          arrList2 = new ArrayList(AsArray("1", "3", "2"));
            ArrayList          arrList3 = new ArrayList(AsArray("1", "2", "3", "4"));
            ArrayList          arrList4 = new ArrayList(AsArray("1", "2"));

            // same size, same elements, same order
            Assert.IsTrue(iaList.Equals(arrList1));
            // same size, same elements, not ordered the same
            Assert.IsFalse(iaList.Equals(arrList2));
            // same size, different elements
            Assert.IsFalse(iaList.Equals(arrList3));
            // different size
            Assert.IsFalse(iaList.Equals(arrList4));
        }
Ejemplo n.º 3
0
        public void TestEqualityBehaviorWithCollection()
        {
            ImmutableArrayList iaList = new ImmutableArrayList(AsArray("1", "2", "3"));
            Queue queue1 = new Queue(AsArray("1", "2", "3"));
            Queue queue2 = new Queue(AsArray("2", "3", "1"));
            Queue queue3 = new Queue(AsArray("1", "5", "3"));
            Queue queue4 = new Queue(AsArray("1", "2"));

            // same size, same elements
            Assert.IsTrue(iaList.Equals(queue1));
            // same size, same elements, not ordered
            Assert.IsTrue(iaList.Equals(queue2));
            // same size, different elements
            Assert.IsFalse(iaList.Equals(queue3));
            // different size
            Assert.IsFalse(iaList.Equals(queue4));
        }