public void ShouldReturnFastestNotNullResponse() { TestSearcherProvider provider = new TestSearcherProvider().AddSearcher(new EmptyResultSearcher("empty searcher")) .AddSearcher(new SlowSearcher(4, "first searher")) .AddSearcher(new SlowSearcher(3, "second searcher")) .AddSearcher(new SlowSearcher(1, "fastest searcher")) .AddSearcher(new ErroredSearcher("errored searcher")); var repo = TestRepoHelper.CreateEmptyRepository(); DefaultSearchService service = new DefaultSearchService(provider, repo); var result = service.SearchAsync("hello world").GetAwaiter().GetResult(); Assert.IsTrue(result.All(x => x.Title.Contains("fastest searcher"))); }
private void btnSearch_Click(object sender, EventArgs e) { var productStatisticsTop5 = new DefaultSearchService(); BindingSource bindingSource = new BindingSource(); try { Log("diagnostics, start test: " + DateTime.UtcNow); bindingSource.DataSource = productStatisticsTop5.DefaultStatisticsTop5(); Log("diagnostics, end test: " + DateTime.UtcNow); gridDefaultStatisticsTop5.AutoGenerateColumns = true; gridDefaultStatisticsTop5.DataSource = bindingSource; gridDefaultStatisticsTop5.AutoResizeColumns(); gridDefaultStatisticsTop5.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { productStatisticsTop5.Close(); } // second var productStatistics = new DefaultSearchService(); BindingSource bindingSource2 = new BindingSource(); try { bindingSource2.DataSource = productStatistics.DefaultStatistics(); gridDefaultStatistics.AutoGenerateColumns = true; gridDefaultStatistics.DataSource = bindingSource2; gridDefaultStatistics.AutoResizeColumns(); gridDefaultStatistics.Refresh(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { productStatistics.Close(); } }
public ActionResult UserActivityIndex() { Logging.ActionLog(Request, "UserActivityIndex ( ASP MVC WCF )"); List <DefaultStatisticsContract> statistics = new DefaultSearchService().DefaultStatistics(); //create a collection of data var transactionCounts = new List <UserActivities>(); foreach (DefaultStatisticsContract contract in statistics) { transactionCounts.Add( new UserActivities() { Day = contract.ActivityDate.Substring(3, 5), Activities = contract.DayCount } ); } // modify data type to make it of array type var xDataMonths = transactionCounts.Select(i => i.Day).ToArray(); var yDataCounts = transactionCounts.Select(i => new object[] { i.Activities }).ToArray(); // instantiate an object of the High charts type var chart = new Highcharts("chart") // define the type of chart .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line }) // overall Title of the chart .SetTitle(new Title { Text = "History" }) // small label below the main Title .SetSubtitle(new Subtitle { Text = "User Activities" }) // load the X values .SetXAxis(new XAxis { Categories = xDataMonths }) // set the Y title .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Number of Transactions" } }) .SetTooltip(new Tooltip { Enabled = true, Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y; }" }) .SetPlotOptions(new PlotOptions { Line = new PlotOptionsLine { DataLabels = new PlotOptionsLineDataLabels { Enabled = true }, EnableMouseTracking = false } }) //load the Y values .SetSeries(new[] { new Series { Name = "Transactions", Data = new Data(yDataCounts) }, //you can add more y data to create a second line // new Series { Name = "Other Name", Data = new Data(OtherData) } }); return(View(chart)); }
public ActionResult PerformanceTimesAndCombo( string commandName ) { Logging.ActionLog(Request, "PerformanceTimesAndCombo: " + commandName + " ( ASP MVC WCF )"); DateTime fromDateTime = DateTime.UtcNow.AddMonths(-1); DateTime untilDateTime = DateTime.UtcNow.AddDays(+5); List <DefaultPerformanceTimeCommandsContract> commands = new DefaultSearchService().DefaultPerformanceTimeCommands(); ViewBag.CommandName = new SelectList( commands.Select(x => new { x.CommandName, x.CommandDisplayName }).Distinct(), "CommandName", "CommandDisplayName" ); List <DefaultPerformanceTimesContract> times = new DefaultSearchService().DefaultPerformanceTimes( commandName ); // create a collection of data var performanceTimes = new List <PerformanceTime>(); foreach (DefaultPerformanceTimesContract contract in times) { performanceTimes.Add( new PerformanceTime() { Date = contract.DateTime.ToString("ss"), Milliseconds = contract.Milliseconds } ); } // modify data type to make it of array type var xDataTimes = performanceTimes.Select(i => i.Date).ToArray(); var yDataMilliseconds = performanceTimes.Select(i => new object[] { i.Milliseconds.ToString() }).ToArray(); // instantiate an object of the High charts type var chart = new Highcharts("chart") // define the type of chart .InitChart(new Chart { DefaultSeriesType = ChartTypes.Line }) // overall Title of the chart .SetTitle(new Title { Text = "nor-port" }) // small label below the main Title .SetSubtitle(new Subtitle { Text = commandName + " from " + fromDateTime.ToShortDateString() + " until " + untilDateTime.ToShortDateString() }) // load the X values .SetXAxis(new XAxis { Categories = xDataTimes }) // set the Y title .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Milliseconds" } }) .SetTooltip( new Tooltip { Enabled = true, Formatter = @"function() { return '<b>'+ this.series.name +'</b><br/>'+ this.x +': '+ this.y; }" }) .SetPlotOptions(new PlotOptions { Line = new PlotOptionsLine { DataLabels = new PlotOptionsLineDataLabels { Enabled = true }, EnableMouseTracking = false } }) // load the Y values .SetSeries(new[] { new Series { Name = "Milliseconds", Data = new Data(yDataMilliseconds) } }); return(View(chart)); }