Пример #1
0
        public void IsValid_ApplyingOneRuleAndRulePass_IsValidReturnValidationResultWithTotal1Passed1Failed0()
        {
            var mock = new Mock <IRule <MoveInfo> >();

            mock.Setup(m => m.Verify(It.IsAny <MoveInfo>())).Returns(true);

            _ruleFactory.Setup(m => m.GetRules(_board.Object)).Returns(new List <IRule <MoveInfo> > {
                mock.Object
            });


            var origin = new Point(8, "H");

            var input = new MoveInfo
            {
                Origin      = origin,
                Destination = origin.AboveLeft(),
                Player      = Player.Black
            };

            var result = _sut.IsValid(input);

            Assert.True(result.IsValid);
            Assert.AreEqual(1, result.TotalRules);
            Assert.AreEqual(1, result.Passed);
            Assert.AreEqual(0, result.Failed);
        }
Пример #2
0
        public void Move(Point origin, Point destination)
        {
            var validation = new MoveInfo
            {
                Origin      = origin,
                Destination = destination,
                Player      = _currentPlayer
            };

            _validator.IsValid(validation);
            var toRemove = GetPositionToRemove(origin, destination);

            _board.Remove(toRemove.X, toRemove.Y);

            MovePlayerPawn(origin, destination);

            SetNextPlayer();
        }