コード例 #1
0
        private async void BeUniqueByAccountNumber_Update_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.ValidateUpdateAsync(default(int), new ApiCustomerRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.AccountNumber, "A");
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        public async void TerritoryID_Update_Valid_Reference()
        {
            Mock <ICustomerRepository> customerRepository = new Mock <ICustomerRepository>();

            customerRepository.Setup(x => x.SalesTerritoryByTerritoryID(It.IsAny <int>())).Returns(Task.FromResult <SalesTerritory>(new SalesTerritory()));

            var validator = new ApiCustomerRequestModelValidator(customerRepository.Object);
            await validator.ValidateUpdateAsync(default(int), new ApiCustomerRequestModel());

            validator.ShouldNotHaveValidationErrorFor(x => x.TerritoryID, 1);
        }