public async Task <OwnerDTO> GetAsync(int ownerId) { Logger.LogTrace($"{nameof(GetAsync)} call for {ownerId}"); var result = await GetOwnerService.GetOwner(new OwnerIdentityModel(ownerId)); return(Mapper.Map <OwnerDTO>(result)); }
public void GetOwner_OwnerNotExists_ThrowsException() { var ownerContainer = new Mock <IOwnerId>(); ownerContainer.Setup(t => t.OwnerId).Returns(1); var ownerDataAccessContainer = new Mock <IOwnerDataAccess>(); ownerDataAccessContainer.Setup(t => t.GetOwner(ownerContainer.Object)).ReturnsAsync((Owner)null); var ownerGetService = new GetOwnerService(ownerDataAccessContainer.Object); Assert.ThrowsAsync <InvalidOperationException>(async() => await ownerGetService.GetOwner(ownerContainer.Object)); }
public async Task GetOwner_OwnerExists_ReturnsOwner() { var ownerContainer = new Mock <IOwnerId>(); var owner = new Owner(); var ownerDataAccessContainer = new Mock <IOwnerDataAccess>(); ownerDataAccessContainer.Setup(t => t.GetOwner(ownerContainer.Object)).ReturnsAsync(owner); var ownerGetService = new GetOwnerService(ownerDataAccessContainer.Object); var result = await ownerGetService.GetOwner(ownerContainer.Object); Assert.AreNotEqual(null, result); }