Esempio n. 1
0
        public async Task SearchImages()
        {
            IImageDataAccess imageDataAccess = Setup();

            using (var scope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
            {
                var imageList = GenerateImages();

                foreach (var item in imageList)
                {
                    await imageDataAccess.SaveImageAsync(item);
                }

                var imagesFromDb = await imageDataAccess.SearchImagesAsync(false, tagName : "Dog");

                Assert.Equal(2, imagesFromDb.Count());

                imagesFromDb = await imageDataAccess.SearchImagesAsync(false, name : "png");

                Assert.Equal(2, imagesFromDb.Count());

                imagesFromDb = await imageDataAccess.SearchImagesAsync(false, description : " ");

                Assert.Equal(4, imagesFromDb.Count());


                imagesFromDb = await imageDataAccess.SearchImagesAsync(false, name : "png", tagName : "Dog");

                Assert.Equal(2, imagesFromDb.Count());

                imagesFromDb = await imageDataAccess.SearchImagesAsync(true, name : "png", tagName : "dog ", description : "family");

                Assert.Single(imagesFromDb);
                Assert.Equal(imagesFromDb.First(), imageList[2]);

                if (_commiteToDB)
                {
                    scope.Complete();
                }
            }
        }
Esempio n. 2
0
 public async Task <IEnumerable <Image> > SearchImagesAsync(bool loadTags, string name = null, string description = null, string tagName = null)
 {
     return(await _imageDataAccess.SearchImagesAsync(loadTags, name, description, tagName));
 }