C#C
C#15mo ago
mellowzippy

Unit Testing ASP.NET async api service

Okay. I am trying to make a unit test for my Customer Service. I tried starting with the Read operation which looks like this in my service:

public async Task<Customer> Read(int customerId)
{
    return await _context.Customers
        .FirstOrDefaultAsync(c => c.CustomerId == customerId);
}

I tried using this as a guide: https://learn.microsoft.com/en-us/ef/ef6/fundamentals/testing/mocking#testing-query-scenarios
Testing with a mocking framework in Entity Framework 6
Was this page helpful?