Exemple #1
0
        public void TestDifference()
        {
            GenericSet <int> gs1 = new GenericSet <int>();

            for (int i = 1; i <= 8; i++)
            {
                gs1.Add(i);
            }
            Console.WriteLine(gs1);

            GenericSet <int> gs2 = new GenericSet <int>();

            for (int i = 5; i <= 15; i++)
            {
                gs2.Add(i);
            }
            Console.WriteLine(gs2);

            GenericSet <int> difference = gs1.Difference(gs2);

            Assert.That(difference.Size, Is.EqualTo(4));
            Assert.That(difference.Contains(15), Is.False);
            Assert.That(difference.Contains(5), Is.False);
            Assert.That(difference.Contains(1), Is.True);
            Assert.That(difference.Contains(4), Is.True);
            Console.WriteLine("Difference: {0}", difference);
        }