public async Task AddLodgmentImageAsync_LodgmentExists_ShouldReturnTheLodgment()
        {
            // Arrange
            expectedLodgment.Id        = lodgmentId;
            expectedLodgment.IsActive  = true;
            expectedLodgment.IsDeleted = false;
            expectedLodgment.Images.Clear();
            context.Add(expectedLodgment);
            context.SaveChanges();

            //Act
            var actualLodgment = await repository.AddLodgmentImageAsync(lodgmentId, urls);

            //Assert
            Assert.IsNotNull(actualLodgment);
            Assert.AreEqual(expectedLodgment.Id, actualLodgment.Id);
            CollectionAssert.AreEqual(urls, actualLodgment.Images.ToList());
        }
Exemplo n.º 2
0
        public async Task <List <string> > UploadImageAsync(int id, FileModel fileModel)
        {
            List <string> urls     = null;
            var           lodgment = await repository.GetLodgmentByIdAsync(id);

            if (lodgment == null)
            {
                throw new KeyNotFoundException();
            }

            urls = await storageService.AddLodgmentImageAsync(id, fileModel);

            await repository.AddLodgmentImageAsync(id, urls);

            return(urls);
        }