concept test in category entity framework

appears as: test, tests, The test, tests, test
Entity Framework Core in Action

This is an excerpt from Manning's book Entity Framework Core in Action.

Listing 2.13 The FilterBooksBy query object method
public static IQueryable<BookListDto> FilterBooksBy(
    this IQueryable<BookListDto> books, 
    BooksFilterBy filterBy, string filterValue)    #1  
{
    if (string.IsNullOrEmpty(filterValue))    #2  
        return books;    #2  

    switch (filterBy)
    {
        case BooksFilterBy.NoFilter:    #3  
            return books;    #3  
        case BooksFilterBy.ByVotes:
            var filterVote = int.Parse(filterValue);    #4  
            return books.Where(x =>    #4  
                   x.ReviewsAverageVotes > filterVote);  #4  
        case BooksFilterBy.ByPublicationYear:             
            if (filterValue == AllBooksNotPublishedString)  #5  
                return books.Where(    #5  
                    x => x.PublishedOn > DateTime.UtcNow);  #5  
            var filterYear = int.Parse(filterValue);    #6  
            return books.Where(    #6  
                x => x.PublishedOn.Year == filterYear    #6  
                  && x.PublishedOn <= DateTime.UtcNow);    #6  
        default:
            throw new ArgumentOutOfRangeException
                (nameof(filterBy), filterBy, null);
    }
}

#1   The method is given both the type of filter and the user-selected filter value.
#2   If the filter value isn't set, it returns IQueryable with no change.
#3   Same for no filter selected—it returns IQueryable with no change.
#4   The filter by votes is a value and above; if there are no reviews for a book, the ReviewsAverageVotes property will be null, and the test always returns false.
#5   If coming soon was picked, you return only books not yet published.
#6   If you have a specific year, you filter on that. You also remove future books (in case the user chose this year’s date).
Table 15.1 Two approaches to checking that two books were loaded by the previous query that was under test
Type Example code
Fluent validation style books.Count().ShouldEqual(2);
Assert method style Assert.Equal(2, books.Count());
Listing 15.11 The foolproof way to create a database that’s up-to-date and empty
[Fact]
public void TestExampleSqlDatabaseOk()
{
    //SETUP
    var options = this
        .CreateUniqueClassOptions<EfCoreContext>();
    using (var context = new EfCoreContext(options))
    {
        context.Database.EnsureDeleted();    #1  
        context.Database.EnsureCreated();    #2  
        //… rest of test removed 

#1   Deletes the currect database (if present)
#2   Creates a new database, using the configuration inside your application’s DbContext

That works every time, and you’re welcome to use it. But if you’re debugging a method by using a unit test that uses this approach, you’ll have a 10-second or so wait before the database is ready for the test. I find that frustrating, so I’ve come up with another approach.