예제 #1
0
        public void PuzzleSet_Subset_Superset_Tests1()
        {
            var sut1       = new PuzzleSet(PuzzleSize.NineByNine);
            var allNumbers = new PuzzleSet(PuzzleSize.NineByNine);

            sut1.AddRange(new byte[] { 1, 2, 3, 4 });
            allNumbers.AddRange(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9 });

            TestContext.WriteLine("lowNumbers overlaps allNumbers: {0}",
                                  sut1.Overlaps(allNumbers));

            TestContext.WriteLine("allNumbers and lowNumbers are equal sets: {0}",
                                  allNumbers.SetEquals(sut1));

            // Show the results of sub/superset testing
            Assert.True(sut1.IsSubsetOf(allNumbers));
            Assert.True(allNumbers.IsSupersetOf(sut1));
            Assert.True(sut1.IsProperSubsetOf(allNumbers));
            Assert.True(allNumbers.IsProperSupersetOf(sut1));

            // Modify allNumbers to remove numbers that are not in sut1.
            allNumbers.IntersectWith(sut1);

            Assert.True(allNumbers.SetEquals(sut1));

            Assert.True(sut1.IsSubsetOf(allNumbers));
            Assert.True(allNumbers.IsSupersetOf(sut1));
            Assert.False(sut1.IsProperSubsetOf(allNumbers));
            Assert.False(allNumbers.IsProperSupersetOf(sut1));
        }