public void AddCustomerAsync_AddNewCustomer_AddsCustomer()
        {
            CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer;
            CustomerModel         customerModel = CustomerBusinessLayerTestFixture.InputCustomerModel;

            Func <Task> test = async() => await businessLayer.AddCustomerAsync(customerModel);

            test.Should()
            .NotThrow();
        }
        public void AddCustomerAsync_AddExistingCustomer_ThrowsArgumentException()
        {
            CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer;
            CustomerModel         customerModel = CustomerBusinessLayerTestFixture.CustomerModelWithId;

            Func <Task> test = async() => await businessLayer.AddCustomerAsync(customerModel);

            test.Should()
            .Throw <ArgumentException>();
        }
示例#3
0
        public async Task <ActionResult> Post([FromBody] CustomerInputModel customer)
        {
            try
            {
                CustomerModel customerModel = (CustomerModel)customer;
                await _customerBusinessLayer.AddCustomerAsync(customerModel);

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