Exemple #1
0
        public static async Task SeedAsync(this CustomerContext context)
        {
            IEnumerable <Customer> customers = TestCustomerData.GetSampleCustomerData();

            context.Customers.AddRange(customers);
            await context.SaveChangesAsync();
        }
        public async Task GivenCustomersExistInDb_WhenGetTop5OldestCustomersCalled_ReturnsCorrectResult()
        {
            // Arrange
            var context = GetInMemoryCustomerContext();
            await context.SeedAsync();

            _repository = new CustomerRepository(context);
            var expected = TestCustomerData.GetSampleCustomerData().Take(5).ToList();

            // Act
            var result = await _repository.GetTop5oldestCustomers();

            // Assert
            Assert.Equal(5, result.Count);
            result.Should().BeEquivalentTo(expected);
        }