コード例 #1
0
        public async void GetById_ShouldReturnCategoryWithSearchedId_WhenCategoryWithSearchedIdExist()
        {
            await using (var context = new BookStoreDbContext(_options))
            {
                var repository = new RepositoryConcreteClass(context);
                var category   = await repository.GetById(2);

                Assert.NotNull(category);
                Assert.IsType <Category>(category);
            }
        }
コード例 #2
0
        public async void GetById_ShouldReturnNull_WhenCategoryWithSearchedIdDoesNotExist()
        {
            await BookStoreHelperTests.CleanDataBase(_options);

            await using (var context = new BookStoreDbContext(_options))
            {
                var repository = new RepositoryConcreteClass(context);
                var category   = await repository.GetById(1);

                Assert.Null(category);
            }
        }
コード例 #3
0
        public async void GetById_ShouldReturnCategoryWithCorrectValues_WhenCategoryExist()
        {
            await using (var context = new BookStoreDbContext(_options))
            {
                var repository = new RepositoryConcreteClass(context);

                var expectedCategories = CreateCategoryList();
                var category           = await repository.GetById(2);

                Assert.Equal(expectedCategories[1].Id, category.Id);
                Assert.Equal(expectedCategories[1].Name, category.Name);
            }
        }