Esempio n. 1
0
        public void Setup()
        {
            _mockRepository     = new MockRepository(MockBehavior.Strict);
            MessageBrokerClient = _mockRepository.Create <IRabbitMessageBrokerClient>(MockBehavior.Loose);
            Factory             = new WebApplicationFactory <Startup>()

                                  .WithWebHostBuilder(x =>
            {
                x.ConfigureAppConfiguration((c, b) => { b.AddConfiguration(ConfigurationBuilderExtensions.GetConfigurationRoot()); });
                x.ConfigureTestServices(s => { s.AddTransient(_ => MessageBrokerClient.Object); });
            })
            ;
        }
        public void Setup()
        {
            Factory = new WebApplicationFactory <Startup>()
                      .WithWebHostBuilder(builder =>
            {
                builder.ConfigureServices(services =>
                {
                    services.RemoveAll(typeof(DbContextOptions));
                    services.RemoveAll(typeof(MicroserviceDbContext));
                    services.AddDbContext <MicroserviceDbContext>();
                    services.AddRabbitMqMessageBroker(ConfigurationBuilderExtensions.GetCustomSection("RabbitMessageBrokerSettings"));
                });
            });

            Client = Factory.CreateClient();
            MessageBrokerClient = Factory.Services.GetService <IRabbitMessageBrokerClient>();
        }