Exemplo n.º 1
0
        public ActionResult Phone(Guid customerId, PhoneNumberUpdateModel model)
        {
            var command = new UpdateCustomerPhoneCommand(customerId, model.PhoneNumber);

            this.commandBus.Execute(command);

            return(this.View());
        }
        public void Handle_Ok()
        {
            var customer = new Mock <Customer>()
            {
                CallBase = true
            };

            customer.Setup(x => x.UpdatePhoneNumber(It.IsAny <PhoneNumber>())).Verifiable();

            var repository = new Mock <ICustomerRepository>();

            repository.Setup(x => x.Get(It.IsAny <Guid>())).Returns(customer.Object);
            repository.Setup(x => x.Save(customer.Object)).Verifiable();

            var sut = new UpdateCustomerPhoneCommandHandler(repository.Object);

            var command = new UpdateCustomerPhoneCommand(Guid.NewGuid(), "+4512345678");

            sut.Handle(command);

            customer.VerifyAll();
            repository.VerifyAll();
        }