public async Task <OwnerDTO> PutAsync(OwnerCreateDTO ownerCreateDto) { Logger.LogTrace($"{nameof(PutAsync)} call"); var result = await CreateOwnerService.CreateOwner(Mapper.Map <OwnerUpdateModel>(ownerCreateDto)); return(Mapper.Map <OwnerDTO>(result)); }
public async Task CreateOwner_OwnerNotExists_CreatesOwner() { var ownerUpdateModel = new OwnerUpdateModel(); var addedOwner = new Owner(); var ownerDataAccessContainer = new Mock <IOwnerDataAccess>(); ownerDataAccessContainer.Setup(t => t.GetOwner(ownerUpdateModel)).ReturnsAsync((Owner)null); ownerDataAccessContainer.Setup(t => t.CreateOwner(ownerUpdateModel)).ReturnsAsync(addedOwner); var ownerCreateService = new CreateOwnerService(ownerDataAccessContainer.Object); var result = await ownerCreateService.CreateOwner(ownerUpdateModel); Assert.AreNotEqual(null, result); }
public void CreateOwner_OwnerExists_ThrowsException() { var ownerUpdateModel = new OwnerUpdateModel(); var existingOwner = new Owner(); var ownerDataAccessContainer = new Mock <IOwnerDataAccess>(); ownerDataAccessContainer.Setup(t => t.CreateOwner(ownerUpdateModel)).ReturnsAsync(existingOwner); ownerDataAccessContainer.Setup(t => t.GetOwner(ownerUpdateModel)).ReturnsAsync(existingOwner); var ownerCreateService = new CreateOwnerService(ownerDataAccessContainer.Object); Assert.ThrowsAsync <ArgumentException>(async() => await ownerCreateService.CreateOwner(ownerUpdateModel)); }