public void UpdateCustomerAsync_NonExistantCustomer_UpdatesCustomer()
        {
            CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer;
            CustomerModel         customerModel = CustomerBusinessLayerTestFixture.InputCustomerModel;
            Guid id = Guid.NewGuid();

            Func <Task> test = async() => await businessLayer.UpdateCustomerAsync(id, customerModel);

            test.Should()
            .Throw <ArgumentException>();
        }
        public void UpdateCustomerAsync_UpdateCustomer_UpdatesCustomer()
        {
            CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer;
            CustomerModel         customerModel = CustomerBusinessLayerTestFixture.InputCustomerModel;
            Guid id = new Guid(CustomerBusinessLayerTestFixture.CustomerGuid);

            Func <Task> test = async() => await businessLayer.UpdateCustomerAsync(id, customerModel);

            test.Should()
            .NotThrow();
        }
Esempio n. 3
0
        public async Task <ActionResult> Put(Guid customerId, [FromBody] CustomerInputModel customer)
        {
            try
            {
                CustomerModel customerModel = (CustomerModel)customer;
                await _customerBusinessLayer.UpdateCustomerAsync(customerId, customerModel);

                return(Accepted());
            }
            catch (ArgumentException ex)
            {
                _logger.LogError(ex, "Error updating customer");
                return(BadRequest());
            }
        }