/// <summary> /// The CategoryRepository class only use the methods from the Repository base class /// </summary> public CategoryRepositoryTests() { // Use this when using a SQLite InMemory database _options = BookStoreHelperTests.BookStoreDbContextOptionsSQLiteInMemory(); BookStoreHelperTests.CreateDataBaseSQLiteInMemory(_options); // Use this when using a EF Core InMemory database //_options = BookStoreHelperTests.BookStoreDbContextOptionsEfCoreInMemory(); //BookStoreHelperTests.CreateDataBaseEfCoreInMemory(_options); }
public async void GetById_ShouldReturnNull_WhenBookWithSearchedIdDoesNotExist() { await BookStoreHelperTests.CleanDataBase(_options); await using var context = new BookStoreDbContext(_options); var bookRepository = new BookRepository(context); var book = await bookRepository.GetById(1); Assert.Null(book); }
public async void GetById_ShouldReturnNull_WhenCategoryWithSearchedIdDoesNotExist() { await BookStoreHelperTests.CleanDataBase(_options); await using (var context = new BookStoreDbContext(_options)) { var categoryRepository = new CategoryRepository(context); var category = await categoryRepository.GetById(1); Assert.Null(category); } }
public async void GetAll_ShouldReturnAnEmptyList_WhenBooksDoNotExist() { await BookStoreHelperTests.CleanDataBase(_options); await using var context = new BookStoreDbContext(_options); var bookRepository = new BookRepository(context); var books = await bookRepository.GetAll(); Assert.NotNull(books); Assert.Empty(books); Assert.IsType <List <Book> >(books); }
public async void GetAll_ShouldReturnAnEmptyList_WhenCategoriesDoNotExist() { await BookStoreHelperTests.CleanDataBase(_options); await using (var context = new BookStoreDbContext(_options)) { var categoryRepository = new CategoryRepository(context); var categories = await categoryRepository.GetAll(); Assert.NotNull(categories); Assert.Empty(categories); Assert.IsType <List <Category> >(categories); } }
public RepositoryTests() { _options = BookStoreHelperTests.BookStoreDbContextOptionsSQLiteInMemory(); BookStoreHelperTests.CreateDataBaseSQLiteInMemory(_options); }