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)); }
public void PuzzleSet_SetEquals_Test1() { var sut1 = new PuzzleSet(PuzzleSize.NineByNine); var sut2 = new PuzzleSet(PuzzleSize.NineByNine); var sut3 = new PuzzleSet(PuzzleSize.NineByNine); sut1.AddRange(new byte[] { 1, 2, 3 }); sut2.AddRange(new byte[] { 1, 2, 3 }); Assert.True(sut1.SetEquals(sut1)); Assert.True(sut1.SetEquals(sut2)); Assert.True(sut2.SetEquals(sut1)); sut2.AddRange(new byte[] { 4, 5, 6 }); sut2.AddRange(new byte[] { 7, 8, 9 }); sut3.AddRange(new byte[] { 7, 8, 9 }); Assert.False(sut1.SetEquals(sut2)); Assert.False(sut2.SetEquals(sut3)); Assert.False(sut1.SetEquals(sut3)); }