Example #1
0
        public void AllShouldReturnCollectionOfGenres()
        {
            var options = new DbContextOptionsBuilder <BookStoreDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;
            //

            var dbContext = new BookStoreDbContext(options);

            var genreServices = new GenreService(dbContext);
            var history       = new Genre
            {
                Name = "History"
            };

            dbContext.Genres.Add(history);

            var music = new Genre
            {
                Name = "Music"
            };

            dbContext.Genres.Add(music);

            dbContext.SaveChanges();

            var genreCollection = genreServices.All().ToList();



            Assert.True(genreCollection.Count == 2);
            Assert.True(genreCollection[0].Name == "History");
            Assert.True(genreCollection[1].Name == "Music");
        }