public void Setup() { options = new DbContextOptionsBuilder <FancyLibraryContext>() .UseInMemoryDatabase(databaseName: "fancy_library_find_book_user") .Options; db = new FancyLibraryContext(options); userBookServices = new UserBookServices(db); db.Users.AddRange(FillUsers()); db.Books.AddRange(FillBooks()); db.UsersBooks.AddRange(FillUsersBooks()); db.SaveChanges(); }
public void DoesMethodReturnZeroWhenUserHasZeroBooks() { options = new DbContextOptionsBuilder <FancyLibraryContext>() .UseInMemoryDatabase(databaseName: "fancy_library_books_count_zero") .Options; db = new FancyLibraryContext(options); services = new UserBookServices(db); db.Books.AddRange(FillBooks()); db.UsersBooks.AddRange(FillUsersBooks()); db.Users.AddRange(FillUsers()); db.SaveChanges(); User user = db.Users.Last(); Assert.That(0, Is.EqualTo(services.GetUserBooksCount(user))); }
public void IsFindingCorrectCountWhenUserHasMoreThanZeroBook() { options = new DbContextOptionsBuilder <FancyLibraryContext>() .UseInMemoryDatabase(databaseName: "fancy_library_books_count_four") .Options; db = new FancyLibraryContext(options); services = new UserBookServices(db); db.Books.AddRange(FillBooks()); db.UsersBooks.AddRange(FillUsersBooks()); db.Users.AddRange(FillUsers()); db.SaveChanges(); User user = db.Users.First(); Assert.That(4, Is.EqualTo(services.GetUserBooksCount(user))); }