예제 #1
0
        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));
        }
예제 #2
0
        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);
        }
예제 #3
0
        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));
        }