Ejemplo n.º 1
0
 public async Task <Image> GetImageAsync(Guid guid, bool loadTags)
 {
     return(await _imageDataAccess.GetImageAsync(guid, loadTags));
 }
Ejemplo n.º 2
0
        public async Task LoadSingleImage()
        {
            IImageDataAccess imageDataAccess = Setup();

            using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var   id        = Guid.NewGuid();
                Image testImage = new Image()
                {
                    Id          = id,
                    Name        = "Bob",
                    Description = "A picture of Bob",
                    Picture     = "dfdsgfs",
                    DateCreated = DateTime.Now,
                    Tags        = new List <Tag>()
                    {
                        new Tag()
                        {
                            TagId    = Guid.NewGuid(),
                            Name     = "Person",
                            ImageKey = id
                        },
                        new Tag()
                        {
                            TagId    = Guid.NewGuid(),
                            Name     = "Friend",
                            ImageKey = id
                        }
                    }
                };
                await imageDataAccess.SaveImageAsync(testImage);

                Image imageFromDb = await imageDataAccess.GetImageAsync(id, false);

                Assert.Equal(0, imageFromDb.Tags.Count);
                Assert.True(compareImages(imageFromDb, testImage));

                imageFromDb = await imageDataAccess.GetImageAsync(id, true);

                Assert.Equal(2, imageFromDb.Tags.Count);
                Assert.True(compareImages(imageFromDb, testImage));

                id        = Guid.NewGuid();
                testImage = new Image()
                {
                    Id          = id,
                    Name        = "Bob",
                    Description = "A picture of Bob",
                    Picture     = "dfdsgfs",
                    DateCreated = DateTime.Now,
                };
                await imageDataAccess.SaveImageAsync(testImage);

                imageFromDb = await imageDataAccess.GetImageAsync(id, true);

                Assert.Equal(0, imageFromDb.Tags.Count);

                if (_commiteToDB)
                {
                    scope.Complete();
                }
            }
        }