Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        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));
        }
Esempio n. 3
0
        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);
        }