コード例 #1
0
        public void PieceMustAcuallyMove()
        {
            Piece             rook = new Rook(Colour.Black);
            StartSquare       d5   = new StartSquare("d5");
            DestinationSquare d8   = new DestinationSquare("d8");
            Move move = new Move(rook.Code, d5, d8);

            BusinessRule target = new PieceMustActuallyMove(move);

            IEnumerable <BusinessRuleViolation> violations = target.CheckRule();

            Assert.IsNotNull(violations);
            Assert.IsFalse(violations.Any());
        }
コード例 #2
0
        public void PieceMustAcuallyMove_ButDoesNot()
        {
            Piece             rook     = new Rook(Colour.Black);
            StartSquare       d5       = new StartSquare("d5");
            DestinationSquare d5AsWell = new DestinationSquare("d5");
            Move move = new Move(rook.Code, d5, d5AsWell);

            BusinessRule target = new PieceMustActuallyMove(move);

            IEnumerable <BusinessRuleViolation> violations = target.CheckRule();

            Assert.AreEqual(1, violations.Count());
            Assert.IsTrue(violations.Any(v => v.ViolationMessage ==
                                         "The start square cannot be the same as the destination square."));
        }