Ejemplo n.º 1
0
        public void UpdateCustomer_ReturnsOk()
        {
            // Arrange
            int id       = 1;
            var customer = new CustomerDto()
            {
                AddressId        = 1,
                PricingPackageId = 1,
                CustomerName     = "firstname"
            };

            // Act
            var mockRepo = new Mock <ICustomerRepository>();

            mockRepo.Setup(x => x.CreateCustomer(It.IsAny <CustomerDto>())).Returns(customer);
            mockRepo.Setup(x => x.EditCustomer(id, It.IsAny <CustomerDto>())).Returns(true);
            var customerManipulation = new CustomerManipulation(mockRepo.Object);
            var controller           = new CustomersController(customerManipulation);

            controller.CreateNewCustomer(customer);

            //update attributes

            customer.CustomerName = "Johndoe";

            var result = controller.EditCustomer(id, customer);

            // Assert
            Assert.IsType <OkObjectResult>(result);
        }