public async void Name_Create_null() { Mock <ITenantRepository> tenantRepository = new Mock <ITenantRepository>(); tenantRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Tenant())); var validator = new ApiTenantRequestModelValidator(tenantRepository.Object); await validator.ValidateCreateAsync(new ApiTenantRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, null as string); }
public async void Name_Update_length() { Mock <ITenantRepository> tenantRepository = new Mock <ITenantRepository>(); tenantRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Tenant())); var validator = new ApiTenantRequestModelValidator(tenantRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiTenantRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 129)); }
private async void BeUniqueByName_Update_Exists() { Mock <ITenantRepository> tenantRepository = new Mock <ITenantRepository>(); tenantRepository.Setup(x => x.ByName(It.IsAny <string>())).Returns(Task.FromResult <Tenant>(new Tenant())); var validator = new ApiTenantRequestModelValidator(tenantRepository.Object); await validator.ValidateUpdateAsync(default(string), new ApiTenantRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, "A"); }