コード例 #1
0
        public async void GetGalleryAsync_stores_up_to_limit()
        {
            var dbName  = Guid.NewGuid().ToString();
            var options = new DbContextOptionsBuilder <GuestBookContext>()
                          .UseInMemoryDatabase(databaseName: dbName).Options;

            var mqDogGalleryRepo = new Mock <IDogGalleryRepo>();

            mqDogGalleryRepo.Setup(dgr => dgr.GetDogGalleryDataAsync()).ReturnsAsync(MockRepo.GetMockGalleryResponse());

            await using (var dbContext = new GuestBookContext(options))
            {
                var gp = new GalleryProvider(mqDogGalleryRepo.Object, dbContext);

                await gp.SaveGalleryImagesAsync(MockRepo.GetImages());

                await gp.SaveGalleryImagesAsync(MockRepo.GetImages());

                await gp.SaveGalleryImagesAsync(MockRepo.GetImages());

                await gp.SaveGalleryImagesAsync(MockRepo.GetImages());

                var totalRecords = dbContext.Gallery.Count();

                totalRecords.Should().BeLessThan(25);
            }
        }
コード例 #2
0
        public async void GetGalleryAsync_Returns_images()
        {
            var dbName  = Guid.NewGuid().ToString();
            var options = new DbContextOptionsBuilder <GuestBookContext>()
                          .UseInMemoryDatabase(databaseName: dbName).Options;

            var mqDogGalleryRepo = new Mock <IDogGalleryRepo>();

            mqDogGalleryRepo.Setup(dgr => dgr.GetDogGalleryDataAsync()).ReturnsAsync(MockRepo.GetMockGalleryResponse());

            await using (var dbContext = new GuestBookContext(options))
            {
                var gp = new GalleryProvider(mqDogGalleryRepo.Object, dbContext);

                var r = await gp.GetGalleryAsync(8);

                r.Length.Should().Be(8);
                r.Select(a => a.Url).Should().NotBeNullOrEmpty();
            }
        }