Exemple #1
0
        public void TestBookDelete()
        {
            var options   = new DbContextOptionsBuilder <MusicSpotDbContext>().UseInMemoryDatabase("bookDelete").Options;
            var dbContext = new MusicSpotDbContext(options);
            var service   = new BookService(dbContext);

            var book = new Book
            {
                Id          = 1,
                Title       = "It",
                Genre       = "Horror",
                ImageUrl    = "aaa",
                Description = "some description",
                UserId      = "aaa"
            };

            dbContext.Books.Add(book);
            dbContext.SaveChanges();

            var result = service.Delete(1);

            Assert.AreEqual(result, true);
            Assert.AreEqual(service.BookExist(1), false);
            Assert.AreNotEqual(result, false);
            Assert.That(book.Id, Is.Not.Null);
        }