public async Task <ActionResult <CustomerModel> > Get(Guid id) { try { return(Ok(await _customerBusinessLayer.GetCustomerAsync(id))); } catch (Exception ex) { _logger.LogInformation(ex, $"Exception occured getting customer {id}"); return(BadRequest()); } }
public void GetCustomerAsync_CustomerNotExistant_ReturnsNull() { CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer; // Random Guid, so we know it's (probably) not there. Guid id = Guid.NewGuid(); CustomerModel customerModelExpected = CustomerBusinessLayerTestFixture.CustomerModelWithId; CustomerModel customerModelResult = null; Func <Task> test = async() => { customerModelResult = await businessLayer.GetCustomerAsync(id); }; test.Should() .NotThrow(); customerModelResult.Should() .BeNull(); }
public void GetCustomerAsync_GetExistingCustomer_GetsExistingCustomer() { CustomerBusinessLayer businessLayer = _fixture.CustomerBusinessLayer; Guid id = new Guid(CustomerBusinessLayerTestFixture.CustomerGuid); CustomerModel customerModelExpected = CustomerBusinessLayerTestFixture.CustomerModelWithId; CustomerModel customerModelResult = null; Func <Task> test = async() => { customerModelResult = await businessLayer.GetCustomerAsync(id); }; test.Should() .NotThrow(); customerModelResult.Should() .NotBeNull() .And .BeEquivalentTo(customerModelExpected); }