public void AddCustomerWithCidShouldThrowValidateException() { //Given a BusinessPartner with a Cid var customerToAdd = new BusinessPartner() { Key = "TestCid" }; //When trying to add the BusinessPartner var aggregateException = _customerService.AddBusinessPartnerAsync(customerToAdd, CancellationToken.None).Exception; //Then the operation should throw a ValidationException aggregateException.Should().NotBeNull(); var error = aggregateException.InnerException; error.Should().BeOfType(typeof(ValidationException)); }
public async Task <BusinessPartnerDto> AddNew([FromBody] BusinessPartnerDto businessPartner, CancellationToken cancellationToken) { _logger.LogDebug($"Adding new customer {businessPartner.Name}"); var result = await _service.AddBusinessPartnerAsync(_mapper.Map <BusinessPartner>(businessPartner), cancellationToken); return(_mapper.Map <BusinessPartnerDto>(result)); }