示例#1
0
        public async void Name_Update_length()
        {
            Mock <ISchemaAPersonRepository> schemaAPersonRepository = new Mock <ISchemaAPersonRepository>();

            schemaAPersonRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new SchemaAPerson()));

            var validator = new ApiSchemaAPersonRequestModelValidator(schemaAPersonRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiSchemaAPersonRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 51));
        }
示例#2
0
        public async void Name_Create_null()
        {
            Mock <ISchemaAPersonRepository> schemaAPersonRepository = new Mock <ISchemaAPersonRepository>();

            schemaAPersonRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new SchemaAPerson()));

            var validator = new ApiSchemaAPersonRequestModelValidator(schemaAPersonRepository.Object);
            await validator.ValidateCreateAsync(new ApiSchemaAPersonRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.Name, null as string);
        }