public async void Name_Update_length() { Mock <IStoreRepository> storeRepository = new Mock <IStoreRepository>(); storeRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Store())); var validator = new ApiStoreRequestModelValidator(storeRepository.Object); await validator.ValidateUpdateAsync(default(int), new ApiStoreRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, new string('A', 51)); }
public async void Name_Create_null() { Mock <IStoreRepository> storeRepository = new Mock <IStoreRepository>(); storeRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult(new Store())); var validator = new ApiStoreRequestModelValidator(storeRepository.Object); await validator.ValidateCreateAsync(new ApiStoreRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.Name, null as string); }
public async void SalesPersonID_Create_Invalid_Reference() { Mock <IStoreRepository> storeRepository = new Mock <IStoreRepository>(); storeRepository.Setup(x => x.SalesPersonBySalesPersonID(It.IsAny <int>())).Returns(Task.FromResult <SalesPerson>(null)); var validator = new ApiStoreRequestModelValidator(storeRepository.Object); await validator.ValidateCreateAsync(new ApiStoreRequestModel()); validator.ShouldHaveValidationErrorFor(x => x.SalesPersonID, 1); }