public async void LastName_Create_length() { Mock <ICustomerRepository> customerRepository = new Mock <ICustomerRepository>(); customerRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Customer())); var validator = new ApiCustomerRequestModelValidator(customerRepository.Object); await validator.ValidateCreateAsync(new ApiCustomerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.LastName, new string('A', 129)); }
public async void StoreID_Create_Valid_Reference() { Mock <ICustomerRepository> customerRepository = new Mock <ICustomerRepository>(); customerRepository.Setup(x => x.StoreByStoreID(It.IsAny <int>())).Returns(Task.FromResult <Store>(new Store())); var validator = new ApiCustomerRequestModelValidator(customerRepository.Object); await validator.ValidateCreateAsync(new ApiCustomerRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.StoreID, 1); }
private async void BeUniqueByAccountNumber_Create_Not_Exists() { Mock <ICustomerRepository> customerRepository = new Mock <ICustomerRepository>(); customerRepository.Setup(x => x.ByAccountNumber(It.IsAny <string>())).Returns(Task.FromResult <Customer>(null)); var validator = new ApiCustomerRequestModelValidator(customerRepository.Object); await validator.ValidateCreateAsync(new ApiCustomerRequestModel()); validator.ShouldNotHaveValidationErrorFor(x => x.AccountNumber, "A"); }
public async void AccountNumber_Create_null() { Mock <ICustomerRepository> customerRepository = new Mock <ICustomerRepository>(); customerRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Customer())); var validator = new ApiCustomerRequestModelValidator(customerRepository.Object); await validator.ValidateCreateAsync(new ApiCustomerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.AccountNumber, null as string); }
public async void TerritoryID_Create_Invalid_Reference() { Mock <ICustomerRepository> customerRepository = new Mock <ICustomerRepository>(); customerRepository.Setup(x => x.SalesTerritoryByTerritoryID(It.IsAny <int>())).Returns(Task.FromResult <SalesTerritory>(null)); var validator = new ApiCustomerRequestModelValidator(customerRepository.Object); await validator.ValidateCreateAsync(new ApiCustomerRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.TerritoryID, 1); }