示例#1
0
        public void Should_Attack(ChessmanType cmType, Size boardSize, Point startCoords, Point[] obstacles,
                                  int result)
        {
            var inst = new DurnevAttackCounter();
            var res  = inst.CountUnderAttack(cmType, boardSize, startCoords, obstacles);

            Assert.Equal(result, res);
        }
示例#2
0
        public void Throw_IfBadSizeBoard()
        {
            var inst  = new DurnevAttackCounter();
            var size  = new Size(0, 0);
            var point = new Point(1, 1);

            foreach (var type in Enum.GetValues(typeof(ChessmanType)))
            {
                Assert.Throws <ArgumentException>(() => inst.CountUnderAttack((ChessmanType)type, size, point, null));
            }
        }
示例#3
0
        public void NotRightTest()
        {
            var inst = new DurnevAttackCounter();
            // Rook - ladja
            var res = inst.CountUnderAttack(ChessmanType.Rook, new Size(3, 2), new Point(1, 1),
                                            new[] { new Point(2, 2), new Point(1, 3) }); //new Point(1, 3) - не на достке, по этому ответ будет 3

            Assert.Equal(2, res);

            // Bishop - slon
            res = inst.CountUnderAttack(ChessmanType.Bishop, new Size(4, 5), new Point(2, 2),
                                        new[] { new Point(3, 3), new Point(1, 3), }); // new Point(3, 3) не из примера, ответ будет 2
            Assert.Equal(3, res);
        }
示例#4
0
        public void Simple()
        {
            var inst = new DurnevAttackCounter();

            output.WriteLine("Testing " + inst.GetType().FullName);
            // Rook - ladja
            var res = inst.CountUnderAttack(ChessmanType.Rook, new Size(3, 2), new Point(1, 1),
                                            new[] { new Point(2, 2), new Point(3, 1) });

            Assert.Equal(2, res);

            // Bishop - slon
            res = inst.CountUnderAttack(ChessmanType.Bishop, new Size(4, 5), new Point(2, 2),
                                        new[] { new Point(3, 3), new Point(1, 3) });
            Assert.Equal(2, res);
        }