Ejemplo n.º 1
0
        /// <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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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);
            }
        }
Ejemplo n.º 6
0
 public RepositoryTests()
 {
     _options = BookStoreHelperTests.BookStoreDbContextOptionsSQLiteInMemory();
     BookStoreHelperTests.CreateDataBaseSQLiteInMemory(_options);
 }