예제 #1
0
        public void SetComparer_SequenceEqualTests()
        {
            List <T> objects = new List <T>()
            {
                CreateT(1), CreateT(2), CreateT(3), CreateT(4), CreateT(5), CreateT(6)
            };

            var set = new PooledSet <PooledSet <T> >()
            {
                RegisterForDispose(new PooledSet <T> {
                    objects[0], objects[1], objects[2]
                }),
                RegisterForDispose(new PooledSet <T> {
                    objects[3], objects[4], objects[5]
                })
            };

            RegisterForDispose(set);

            var noComparerSet = new PooledSet <PooledSet <T> >()
            {
                RegisterForDispose(new PooledSet <T> {
                    objects[0], objects[1], objects[2]
                }),
                RegisterForDispose(new PooledSet <T> {
                    objects[3], objects[4], objects[5]
                })
            };

            RegisterForDispose(noComparerSet);

            var comparerSet = new PooledSet <PooledSet <T> >(PooledSet <T> .CreateSetComparer())
            {
                RegisterForDispose(new PooledSet <T> {
                    objects[0], objects[1], objects[2]
                }),
                RegisterForDispose(new PooledSet <T> {
                    objects[3], objects[4], objects[5]
                })
            };

            RegisterForDispose(comparerSet);

            Assert.False(noComparerSet.SequenceEqual(set));
            Assert.True(noComparerSet.SequenceEqual(set, PooledSet <T> .CreateSetComparer()));
            Assert.False(comparerSet.SequenceEqual(set));
        }