Exemple #1
0
        public async Task AllAsyncShouldReturnCorrectCustomersSortedByDescription()
        {
            var db = DbInfrastructure.GetDatabase();
            var serviceProviderMock = new Mock <IServiceProvider>();
            var customer            = await DbInfrastructure.SeedCustomer(db);

            await DbInfrastructure.SeedCustomers(100, 10, db);

            var orderService = new PurchaseOrderService(db, new SortStrategyParser(serviceProviderMock.Object));

            await DbInfrastructure.SeedOrdersByCustomer(db, customer);

            const string Description = "description";

            for (var i = 1; i <= 8; i++)
            {
                var orders = await orderService.AllAsync <OrderViewModel>(i, customer.Id, Description);

                orders
                .Should()
                .HaveCount(WebConstants.OrdersPerPage);

                orders
                .Should()
                .BeInAscendingOrder(c => c.Description);

                orders
                .Should()
                .NotContain(c => c.Status == Status.Deleted);
            }
        }
Exemple #2
0
        public async Task AllAsyncShouldReturnCorrectCustomersWithoutSort()
        {
            var db = DbInfrastructure.GetDatabase();

            await DbInfrastructure.SeedCustomers(100, 10, db);

            var serviceProviderMock = new Mock <IServiceProvider>();
            var customerService     = new CustomerService(db, new SortStrategyParser(serviceProviderMock.Object));

            IEnumerable <CustomerViewModel> customers;

            for (var i = 1; i <= 8; i++)
            {
                customers = await customerService.AllAsync <CustomerViewModel>(i, string.Empty);

                customers
                .Should()
                .HaveCount(WebConstants.CustomersPerPage);

                customers
                .Should()
                .BeInDescendingOrder(c => c.CreatedOn);

                customers
                .Should()
                .NotContain(c => c.Status == Status.Deleted);
            }

            customers = await customerService.AllAsync <CustomerViewModel>(9, string.Empty);

            customers
            .Should()
            .HaveCount(4);
        }
Exemple #3
0
        public async Task CountAsyncShouldReturnCorrectCountOfNonDeletedCustomers()
        {
            var db = DbInfrastructure.GetDatabase();

            const int Customers = 150;

            await DbInfrastructure.SeedCustomers(Customers, 20, db);

            var serviceProviderMock = new Mock <IServiceProvider>();
            var customerService     = new CustomerService(db, new SortStrategyParser(serviceProviderMock.Object));

            var customersCount = await customerService.CountAsync();

            customersCount
            .Should()
            .Be(Customers);
        }
Exemple #4
0
        public async Task CountByCustomerAsyncShouldReturnCorrectCount()
        {
            var db = DbInfrastructure.GetDatabase();
            var serviceProviderMock = new Mock <IServiceProvider>();
            var customer            = await DbInfrastructure.SeedCustomer(db);

            await DbInfrastructure.SeedCustomers(100, 10, db);

            var orderService = new PurchaseOrderService(db, new SortStrategyParser(serviceProviderMock.Object));

            await DbInfrastructure.SeedOrdersByCustomer(db, customer);

            var ordersCountByCustomer = await orderService.CountByCustomerAsync(customer.Id);

            ordersCountByCustomer
            .Should()
            .Be(150);
        }