Пример #1
0
        public async Task TorSharpToolFetcher_UseExistingTools()
        {
            using (var te = TestEnvironment.Initialize(_output))
            {
                // Arrange
                var settings = te.BuildSettings();
                settings.ReloadTools      = true;
                settings.UseExistingTools = true;

                using (var httpClientHandler = new HttpClientHandler())
                    using (var requestCountHandler = new RequestCountHandler {
                        InnerHandler = httpClientHandler
                    })
                        using (var loggingHandler = new LoggingHandler(_output)
                        {
                            InnerHandler = requestCountHandler
                        })
                            using (var httpClient = new HttpClient(requestCountHandler))
                                using (var proxy = new TorSharpProxy(settings))
                                {
                                    _output.WriteLine(settings);
                                    var fetcherA = _httpFixture.GetTorSharpToolFetcher(settings, httpClient);
                                    await fetcherA.FetchAsync();

                                    var requestCount = requestCountHandler.RequestCount;

                                    // Act
                                    var fetcherB = _httpFixture.GetTorSharpToolFetcher(settings, httpClient);
                                    await fetcherB.FetchAsync();

                                    // Assert
                                    Assert.True(requestCount > 0, "The should be at least one request.");
                                    Assert.Equal(requestCount, requestCountHandler.RequestCount);
                                    Assert.NotNull(ToolUtility.GetLatestToolOrNull(settings, ToolUtility.GetPrivoxyToolSettings(settings)));
                                    Assert.NotNull(ToolUtility.GetLatestToolOrNull(settings, ToolUtility.GetTorToolSettings(settings)));
                                }
            }
        }