public async Task GetProductByIdAsync_WhenFailed_ReturnNull() { var container = Registrations(); await using var scope = container.BeginLifetimeScope(); var options = scope.Resolve <DbContextOptions <TechnicalTestDbContext> >(); await using var context = new TechnicalTestDbContext(options); await SeedMockDataAsync(context); var service = new ProductService(context); var result = await service.GetProductByIdAsync(10, CancellationToken.None); Assert.That(result == null); }
public async Task GetProductByIdAsync_WhenSucceded_ReturnGetProductByIdQueryLookupModel() { var container = Registrations(); await using var scope = container.BeginLifetimeScope(); var options = scope.Resolve <DbContextOptions <TechnicalTestDbContext> >(); await using var context = new TechnicalTestDbContext(options); await SeedMockDataAsync(context); var service = new ProductService(context); var result = await service.GetProductByIdAsync(1, CancellationToken.None); Assert.That(result.Name.Equals("Product1")); }