コード例 #1
0
        public async Task <IActionResult> GetCustomers(string firstName, string lastName)
        {
            IServiceProvider provider = TestServiceProvider.CreateProvider();

            using (IServiceScope scope = provider.CreateScope())
            {
                await SeedRepository(scope.ServiceProvider);

                CustomersController controller = scope.ServiceProvider.GetRequiredService <CustomersController>();

                return(await controller.GetCustomers(firstName, lastName, scope.ServiceProvider.GetRequiredService <GetCustomersCommand>()));
            }
        }
コード例 #2
0
        public async Task <IActionResult> AddCustomer(Customer customer)
        {
            IServiceProvider provider = TestServiceProvider.CreateProvider(_setup);

            using (IServiceScope scope = provider.CreateScope())
            {
                CustomersController controller = scope.ServiceProvider.GetRequiredService <CustomersController>();
                IActionResult       result     = await controller.AddCustomer(customer, scope.ServiceProvider.GetRequiredService <AddCustomerCommand>());

                await SnapshotRepository(scope.ServiceProvider);

                return(result);
            }
        }
コード例 #3
0
        public async Task <IActionResult> DeleteCustomer(string customerId)
        {
            IServiceProvider provider = TestServiceProvider.CreateProvider();

            using (IServiceScope scope = provider.CreateScope())
            {
                await SeedRepository(scope.ServiceProvider);

                CustomersController controller = scope.ServiceProvider.GetRequiredService <CustomersController>();
                IActionResult       result     = await controller.DeleteCustomer(customerId, scope.ServiceProvider.GetRequiredService <DeleteCustomerCommand>());

                await SnapshotRepository(scope.ServiceProvider);

                return(result);
            }
        }