Пример #1
0
        public void StaticThrowIfNotSatisfiedThrowsNoExceptionWhenThereAreNoViolations()
        {
            BusinessRule target = new RuleThatNeverHasAViolation();

            BusinessRule.ThrowIfNotSatisfied(target);

            // Assert that no exception has been thrown
        }
Пример #2
0
        public void MakeMove(MakeMove command)
        {
            BusinessRule.ThrowIfNotSatisfied(
                new PieceMustActuallyMove(command.Move)
                & new PieceMustOccupyStartingSquare(Board, command.Move)
                & new MoveIsValidForPiece(Board, command.Move)
                // & new MovePathIsUnobstructed(Board, command.Move)
                );

            MoveMade e = command.Move.MapToMoveMade(this.Id);

            RaiseEvent(e);
        }
Пример #3
0
        public void StaticThrowIfNotSatisfiedThrowsBusinessRuleViolationException()
        {
            BusinessRule target = new RuleThatAlwaysHasOneViolation();

            Action act = () =>
            {
                BusinessRule.ThrowIfNotSatisfied(target);
            };

            var ex = Assert.ThrowsException <BusinessRuleViolationException>(act);

            Assert.AreEqual("Rule Violations: 1 violations have been detected.", ex.Message);
            Assert.AreEqual(1, ex.Violations.Count());
            Assert.IsTrue(ex.Violations.Any(v => v.ViolationMessage == "Always one violation"));
        }