public async Task GetClients_ShouldIncludeCategoriesWithClients_WhenCategoriesAssigned() { // Arrange using (var context = new AppDbContext(_dbContextOptions)) { context.Clients.Add(new Client { Category = new Category { Name = "a" } }); context.Clients.Add(new Client { Category = new Category { Name = "b" } }); await context.SaveChangesAsync(); } // Act using (var context = new AppDbContext(_dbContextOptions)) { var service = new ClientsDataService(context); var result = await service.GetClients(); // Assert result.First().Category.Name.Should().Be("a"); result.Last().Category.Name.Should().Be("b"); } }
public async Task GetClients_ShouldReturnTwoClients_WhenTwoClientsFoundInDatabase() { // Arrange using (var context = new AppDbContext(_dbContextOptions)) { context.Clients.AddRange(new Client(), new Client()); await context.SaveChangesAsync(); } // Act using (var context = new AppDbContext(_dbContextOptions)) { var service = new ClientsDataService(context); var result = await service.GetClients(); // Assert result.Should().HaveCount(2); } }