Esempio n. 1
0
        public void ErrorCreateCustomerAddress(string address, int errorCode)
        {
            var command       = new CreateCustomerCommand(null, null, null, address, _appSettings);
            var commandResult = new CustomerCommandHandler(_mapper, _customerRepo.Object, _userRepo.Object)
                                .Handle(command, new CancellationToken()).Result;

            Assert.True(commandResult.HasError(errorCode));
        }
Esempio n. 2
0
        public void ErrorUpdateCustomerPassword(string password, int errorCode)
        {
            var command       = new UpdateCustomerCommand(0, null, null, password, null, false, _appSettings);
            var commandResult = new CustomerCommandHandler(_mapper, _customerRepo.Object, _userRepo.Object)
                                .Handle(command, new CancellationToken()).Result;

            Assert.True(commandResult.HasError(errorCode));
        }
Esempio n. 3
0
        public void ErrorUpdateCustomerIdCustomer()
        {
            var command       = new UpdateCustomerCommand(0, null, null, null, null, false, _appSettings);
            var commandResult = new CustomerCommandHandler(_mapper, _customerRepo.Object, _userRepo.Object)
                                .Handle(command, new CancellationToken()).Result;

            Assert.True(commandResult.HasError(1009));
        }
Esempio n. 4
0
        public void ErrorCreateCustomerEmailExists()
        {
            _userRepo.Setup((s) => s.EmailExists(It.IsAny <string>())).Returns(Task.FromResult(true));

            var command       = new CreateCustomerCommand("Luciano Pereira", "[email protected]", "abc123", "New York", _appSettings);
            var commandResult = new CustomerCommandHandler(_mapper, _customerRepo.Object, _userRepo.Object)
                                .Handle(command, new CancellationToken()).Result;

            Assert.True(commandResult.HasError(2002));
        }
Esempio n. 5
0
        public void ErrorUpdateCustomerIdCustomerNotExists()
        {
            _customerRepo.Setup(s => s.IdCustomerExists(It.IsAny <int>())).Returns(Task.FromResult(false));

            var command       = new UpdateCustomerCommand(1, "Luciano Pereira", "[email protected]", "abc123", "New York", true, _appSettings);
            var commandResult = new CustomerCommandHandler(_mapper, _customerRepo.Object, _userRepo.Object)
                                .Handle(command, new CancellationToken()).Result;

            Assert.True(commandResult.HasError(2005));
        }
Esempio n. 6
0
        public void ErrorUpdateCustomerIdUserNotExists()
        {
            _customerRepo.Setup(s => s.IdCustomerExists(It.IsAny <int>())).Returns(Task.FromResult(true));
            var customer = new Domain.Entities.Customer(1, 1, "MY NAME", "MY ADDRESS");

            _customerRepo.Setup(s => s.GetCustomer(It.IsAny <int>())).Returns(Task.FromResult(customer));
            _userRepo.Setup((s) => s.IdUserExists(It.IsAny <int>())).Returns(Task.FromResult(false));

            var command       = new UpdateCustomerCommand(1, "Luciano Pereira", "[email protected]", "abc123", "New York", true, _appSettings);
            var commandResult = new CustomerCommandHandler(_mapper, _customerRepo.Object, _userRepo.Object)
                                .Handle(command, new CancellationToken()).Result;

            Assert.True(commandResult.HasError(2000));
        }
Esempio n. 7
0
        public void ErrorUpdateCustomerEmailExistsDifferentUser()
        {
            _customerRepo.Setup(s => s.IdCustomerExists(It.IsAny <int>())).Returns(Task.FromResult(true));
            var customer = new Servico.Entities.Customer(1, 1, "MY NAME", "MY ADDRESS");

            _customerRepo.Setup(s => s.GetCustomer(It.IsAny <int>())).Returns(Task.FromResult(customer));
            _userRepo.Setup((s) => s.EmailExistsDifferentUser(It.IsAny <int>(), It.IsAny <string>())).Returns(Task.FromResult(true));

            var command       = new UpdateCustomerCommand(1, "Cassio Guilhermy", "[email protected]", "cass123", "Gyn", true, _appSettings);
            var commandResult = new CustomerCommandHandler(_mapper, _customerRepo.Object, _userRepo.Object)
                                .Handle(command, new CancellationToken()).Result;

            Assert.True(commandResult.HasError(2003));
        }