示例#1
0
        public void InvalidData(
            EvaluationEngine engine)
        {
            IValidationResult answer = null;

            "establish"._(() =>
            {
                engine = new EvaluationEngine();

                engine.Solve <IsDataValid, IValidationResult, Data>()
                .AggregateWithValidationAggregator()
                .ByEvaluating(q => new NameSetRule())
                .ByEvaluating(q => new DescriptionSetRule());
            });

            "when validating invalid data"._(() =>
            {
                answer = engine.Answer(
                    new IsDataValid(),
                    new Data
                {
                    Name = null,
                });
            });

            "it should return invalid validation result"._(() =>
            {
                answer.Valid.Should().BeFalse();
            });

            "it should return validation result with violations"._(() =>
            {
                answer.Violations.Should().HaveCount(1);
            });

            "it should return violations with reason set by failing rule"._(() =>
            {
                answer.Violations.Single().Reason.Should().Be(ViolationReason);
            });
        }