Ejemplo n.º 1
0
        public void Test_ApplicationHost_PollyRetry()
        {
            // Arrange
            var builder    = new AppHostBuilder(true);
            var collection = new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>("setting:0", "1"),
                new KeyValuePair <string, string>("setting:1", "2")
            };

            // Act - Configure the application host.
            var processHost = builder
                              .ConfigureAppConfiguration(config => config.AddInMemoryCollection(collection))
                              .AddRetryWaitPolicy <HttpRequestException>(2, 2)
                              .AddHostedProcess <HttpErrorService>()
                              .Build(); // Build the host - this wires up dependencies.

            var service = ((AppHost)processHost)._serviceProvider.GetService <HttpErrorService>();

            processHost.RunOnce();

            // Assert
            service.CallCount.Should().Be(3);
        }