Exemplo n.º 1
0
        public Fixture()
        {
            Db = DbTestClientFactory.Create <DatabaseContext>(ConfigurationKeys.DatabaseConnectionKey, e => new DatabaseContext(e), ConfigurationKeys.SqlServerOptionsAction);

            var configurationBuilder = new ConfigurationBuilder()
                                       .AddJsonFile("appsettings.Test.json");

            var configurationRoot = configurationBuilder.Build();

            var webHostBuilder = new WebHostBuilder()
                                 .UseStartup <Startup>()
                                 .UseConfiguration(configurationRoot);

            var services = new ServiceCollection();

            services.AddSingleton(typeof(TestServer), serviceProvider => new TestServer(webHostBuilder));
            services.AddSingleton <IJsonSerializer, JsonSerializer>();

            services.AddTransient <IHttpClientFactory, TestServerHttpClientFactory>();
            services.AddHttpClient <ICustomerControllerClient, CustomerControllerClient>();
            services.AddHttpClient <IOrderControllerClient, OrderControllerClient>();
            services.AddHttpClient <IProductControllerClient, ProductControllerClient>();
            services.AddTransient <IApiClient, ApiClient>();

            var serviceProvider = services.BuildServiceProvider();

            Api = serviceProvider.GetRequiredService <IApiClient>();
        }
Exemplo n.º 2
0
        public ControllerFixture()
        {
            Web = WebTestClientFactory.Create <Startup>();
            Db  = DbTestClientFactory.Create <DatabaseContext>(ConfigurationKeys.DatabaseConnectionKey, e => new DatabaseContext(e));

            Api = new ApiHttpService(Web.ControllerClientFactory);
        }
Exemplo n.º 3
0
        public ServiceFixture()
        {
            var configuration = ConfigurationRootFactory.Create();
            var services      = new ServiceCollection();

            services.AddModules(configuration);

            Db = DbTestClientFactory.Create <DatabaseContext>(ConfigurationKeys.DatabaseConnectionKey, e => new DatabaseContext(e));

            ServiceProvider = services.BuildServiceProvider();

            MyFoos = GetService <IMyFooService>();
        }
Exemplo n.º 4
0
        public ServiceFixture()
        {
            var configuration = ConfigurationRootFactory.Create();
            var services      = new ServiceCollection();

            services.AddModules(configuration);

            Db = DbTestClientFactory.Create <DatabaseContext>(ConfigurationKeys.DatabaseConnectionKey, e => new DatabaseContext(e), ConfigurationKeys.SqlServerOptionsAction);

            ServiceProvider = services.BuildServiceProvider();

            Customers = GetService <ICustomerService>();
            Orders    = GetService <IOrderService>();
            Products  = GetService <IProductService>();
        }