Exemple #1
0
        public void PuzzleSet_AddRangeCheck_Test1()
        {
            var sut = new PuzzleSet(PuzzleSize.FourByFour);

            Assert.Throws <ArgumentOutOfRangeException>(() => sut.Add(0));
            Assert.Throws <ArgumentOutOfRangeException>(() => sut.Add(5));

            sut = new PuzzleSet(PuzzleSize.NineByNine);
            Assert.Throws <ArgumentOutOfRangeException>(() => sut.Add(0));
            Assert.Throws <ArgumentOutOfRangeException>(() => sut.Add(10));

            sut = new PuzzleSet(PuzzleSize.SixteenBySixteen);
            Assert.Throws <ArgumentOutOfRangeException>(() => sut.Add(0));
            Assert.Throws <ArgumentOutOfRangeException>(() => sut.Add(17));
        }
Exemple #2
0
        public void PuzzleSet_GetEnumerator_Test1()
        {
            var sut  = new PuzzleSet(PuzzleSize.NineByNine);
            var list = new List <byte>();

            for (byte i = 1; i < 6; i++)
            {
                sut.Add(i);
                list.Add(i);
            }

            Assert.Equal(sut, list);
        }
Exemple #3
0
        public void PuzzleSet_AddSyncsWithCount_Test2()
        {
            foreach (var size in new[]
            {
                PuzzleSize.FourByFour,
                PuzzleSize.NineByNine,
                PuzzleSize.SixteenBySixteen
            })
            {
                var sut = new PuzzleSet(size);
                foreach (var value in Enumerable.Range(1, sut.MaxValue).Select(Convert.ToByte))
                {
                    Assert.True(sut.Add(value));
                    Assert.Equal(value, sut.Count);
                }

                foreach (var value in Enumerable.Range(1, sut.MaxValue).Select(Convert.ToByte))
                {
                    Assert.False(sut.Add(value));
                    Assert.Equal(sut.MaxValue, sut.Count);
                }
            }
        }
Exemple #4
0
        public void PuzzleSet_Contains_Test1()
        {
            foreach (var size in new[]
            {
                PuzzleSize.FourByFour,
                PuzzleSize.NineByNine,
                PuzzleSize.SixteenBySixteen
            })
            {
                var sut = new PuzzleSet(size);
                foreach (var value in Enumerable.Range(1, sut.MaxValue).Select(Convert.ToByte))
                {
                    Assert.True(sut.Add(value));
                    Assert.Contains(value, sut);

                    sut.Clear();
                    Assert.DoesNotContain(value, sut);
                }
            }
        }