Ejemplo n.º 1
0
        public async void LastName_Update_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.ValidateUpdateAsync(default(int), new ApiCustomerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.LastName, new string('A', 129));
        }
Ejemplo n.º 2
0
        public async void AccountNumber_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.AccountNumber, new string('A', 11));
        }
Ejemplo n.º 3
0
        private async void BeUniqueByAccountNumber_Update_Exists()
        {
            Mock <ICustomerRepository> customerRepository = new Mock <ICustomerRepository>();

            customerRepository.Setup(x => x.ByAccountNumber(It.IsAny <string>())).Returns(Task.FromResult <Customer>(new Customer()));
            var validator = new ApiCustomerRequestModelValidator(customerRepository.Object);

            await validator.ValidateUpdateAsync(default(int), new ApiCustomerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.AccountNumber, "A");
        }
        public async void FirstName_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.FirstName, null as string);
        }
Ejemplo n.º 5
0
        public async void StoreID_Create_Invalid_Reference()
        {
            Mock <ICustomerRepository> customerRepository = new Mock <ICustomerRepository>();

            customerRepository.Setup(x => x.StoreByStoreID(It.IsAny <int>())).Returns(Task.FromResult <Store>(null));

            var validator = new ApiCustomerRequestModelValidator(customerRepository.Object);

            await validator.ValidateCreateAsync(new ApiCustomerRequestModel());

            validator.ShouldHaveValidationErrorFor(x => x.StoreID, 1);
        }
Ejemplo n.º 6
0
        public async void TerritoryID_Update_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.ValidateUpdateAsync(default(int), new ApiCustomerRequestModel());

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