public void Run() { try { var cts = SetupUserInputCancellationTokenSource(); var logger = PusherEventSource.Log; var loggingEventListeners = SetupLoggingEventListeners(_webSettings, logger).ToList(); var urlHeaders = new Dictionary <string, string>(); var contentType = string.Empty; foreach (var item in _webSettings.UrlHeaders) { urlHeaders.Add(item.Name, item.Value); } string content = null; if (_webSettings.Content != null) { byte[] data = Convert.FromBase64String(_webSettings.Content); content = Encoding.UTF8.GetString(data); } var pusher = new LoadPusher(new HttpGatewayProvider(logger), logger); var spec = new BasicRunSpecification( _webSettings.TimeDuration, _webSettings.StartCount, _webSettings.MaxRequestCount, _webSettings.Url, _webSettings.Timeout, _webSettings.Verb, content, urlHeaders); try { pusher.PushLoadAsync(spec, cts.Token).Wait(cts.Token); Console.ReadLine(); } finally { DisableLoggingEventListeners(loggingEventListeners, logger); } Console.WriteLine("\nPress <Enter> to terminate."); Console.ReadLine(); } catch (Exception ex) { _logger.LogError(ex.ToString()); } }
public async Task Should_Log_All_Grouping_Summaries_For_Basic_Specification(int timeDuration) { var spec = new BasicRunSpecification(timeDuration, 100, 200, "http://localhost/", 1000, "GET", null); await loadPusher.PushLoadAsync(spec, CancellationToken.None); mockPusherLogger.Verify( logger => logger.LogRequestGroupingSummary(It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>()), Times.Exactly(timeDuration), "LogRequestGroupingSummary should be called the same number of times as the duration of the load run."); }
public async Task Should_Trigger_Incrementing_Requests_For_Basic_Specification(int timeDuration) { var spec = new BasicRunSpecification(timeDuration, 100, 200, "http://localhost/", 1000, "GET", null); await loadPusher.PushLoadAsync(spec, CancellationToken.None); var expectedResponsesCount = Enumerable.Range(100, timeDuration).Sum(); //mockPusherLogger.Verify( // logger => // logger.LogResponse(It.IsAny<int>(), It.IsAny<string>(), It.IsAny<bool>(), It.IsAny<string>(), // It.IsAny<int>(), It.IsAny<string>()), // Times.Exactly(expectedResponsesCount), // "LogResponse should be called the total number of times as the summation of the starting count with the incrementing duration of the load run."); }