Exemplo n.º 1
0
        private void StrictSetCompliment <S1, S2>() where S1 : IStrictSet <int>, new() where S2 : IStrictSet <int>, new()
        {
            var s1 = new S1();
            var s2 = new S2();

            Fill(s1, 0, 1000);
            Fill(s2, 0, 2000);
            var result = s1.Compliment(s2);

            for (var i = 0; i < 1000; i++)
            {
                Assert.False(s1.Contains(i));
                Assert.False(result.Contains(i));
            }
            for (var i = 1000; i < 2000; i++)
            {
                Assert.True(s1.Contains(i));
                Assert.True(result.Contains(i));
            }

            var s3 = new S1();
            var s4 = new S2();

            Fill(s4, 0, 1000);
            var result2 = s3.Compliment(s4);

            Assert.True(s3.IsEqualWith(s4));
            Assert.True(result2.IsEqualWith(s4));
            for (var i = 0; i < 1000; i++)
            {
                Assert.True(s3.Contains(i));
                Assert.True(result2.Contains(i));
            }

            var s5 = new S1();
            var s6 = new S2();

            Fill(s5, 0, 1000);
            Fill(s6, 500, 1000);
            Assert.Throws(typeof(InvalidOperationException), () => s5.Compliment(s6));

            var s7      = new S1();
            var s8      = new S2();
            var result3 = s7.Compliment(s8);

            Assert.True(s7.IsEqualWith(new S1()));
            Assert.True(s7.IsEqualWith(new S2()));
            Assert.True(result3.IsEqualWith(new S1()));
            Assert.True(result3.IsEqualWith(new S2()));
        }
Exemplo n.º 2
0
        private void StrictSetEqual <S1, S2>() where S1 : IStrictSet <int>, new() where S2 : IStrictSet <int>, new()
        {
            var s1 = new S1();
            var s2 = new S2();

            Fill(s1, 0, 10000);
            Fill(s2, 0, 5000);
            Assert.False(s1.IsEqualWith(s2));

            var s3 = new S1();
            var s4 = new S2();

            Fill(s3, 0, 1000);
            Fill(s4, 0, 1000);
            Assert.True(s3.IsEqualWith(s4));

            var s5 = new S1();
            var s6 = new S2();

            Fill(s5, 0, 1000);
            Fill(s6, 1000, 1000);
            Assert.False(s5.IsEqualWith(s6));

            var s7 = new S1();
            var s8 = new S2();

            Fill(s7, 0, 1000);
            Fill(s8, 0, 1999);
            Assert.False(s7.IsEqualWith(s8));

            var s9  = new S1();
            var s10 = new S2();

            Assert.True(s9.IsEqualWith(s10));
        }