Esempio n. 1
0
 public async Task TestQueryNull()
 {
     var query = new QueryA();
     var self = new QueryAndValidator(query, null);
     var result = await QueryValidationSteps.Validate(self);
     result.ShouldBe(query);
 }
Esempio n. 2
0
 public async Task TestQueryValid()
 {
     var query = new QueryA();
     var self = new QueryAndValidator(query, _validValidator);
     var result = await QueryValidationSteps.Validate(self);
     await _validValidator.Received().ValidateAsync(query);
     result.ShouldBe(query);
 }
Esempio n. 3
0
        public async Task TestValidateQuery()
        {
            var queryA = new QueryA();
            var result = await Validate.Query(queryA)
                .ThenFindValidator(_validatorRepo.FindValidatorFor)
                .ThenCreateValidator(t => Default.CreateHandler(t) as IValidator)
                .ThenValidate();

            result.ShouldBe(queryA);
        }
 public void TestQueryNull()
 {
     var query = new QueryA();
     var self = new QueryAndType(query);
     var result = QueryValidationSteps.FindValidator(
         self,
         t =>
         {
             t.ShouldBe(self.Type);
             return null;
         });
     result.ValidatorType.ShouldBe(null);
     result.Query.ShouldBe(query);
 }
 public void TestQuery()
 {
     var query = new QueryA();
     var self = new QueryAndType(query);
     var result = QueryValidationSteps.FindValidator(
         self,
         t =>
         {
             t.ShouldBe(self.Type);
             return typeof(TestValidator<QueryA>);
         });
     result.ValidatorType.ShouldBe(typeof(TestValidator<QueryA>));
     result.Query.ShouldBe(query);
 }
 public void TestQuery()
 {
     var query = new QueryA();
     var testValidator = new TestValidator<QueryA>();
     var self = new QueryAndValidatorType(query, typeof(TestValidator<QueryA>));
     var result = QueryValidationSteps.CreateValidator(
         self,
         t =>
         {
             t.ShouldBe(typeof(TestValidator<QueryA>));
             return testValidator;
         });
     result.Query.ShouldBe(query);
     result.Validator.ShouldBe(testValidator);
 }
 public void TestQueryNullIn()
 {
     var query = new QueryA();
     var self = new QueryAndValidatorType(query, null);
     var spy = Substitute.For<Func<Type, IValidator>>();
     var result = QueryValidationSteps.CreateValidator(self, spy);
     result.Query.ShouldBe(query);
     result.Validator.ShouldBe(null);
     spy.DidNotReceive().Invoke(Arg.Any<Type>());
 }
Esempio n. 8
0
        public void TestQueryInvalid()
        {
            var query = new QueryA();
            var self = new QueryAndValidator(query, _invalidValidator);
            var result = Should.Throw<Qvc.Validation.ValidationException>(async () => await QueryValidationSteps.Validate(self));
            _invalidValidator.Received().ValidateAsync(query);

            result.Violations.Single().FieldName.ShouldBe("fieldCamelCase");
            result.Violations.Single().Message.ShouldBe("error");
        }