public async Task Execution_Chart_Report_In_Mongo_Test() { if (!_context.AllowMongoDB) { Assert.True(true); return; } // Arrange var optionsMock = Mock.Of <IOptionsMonitor <MongoOptions> >(_ => _.CurrentValue == _context.MongoOptions); Mock <IDatabaseServiceProvider> mockDatabaseServiceProvider = new Mock <IDatabaseServiceProvider>(); mockDatabaseServiceProvider .Setup(a => a.GetOneDatabaseConnectionAsync(It.IsAny <string>())) .Returns(Task.FromResult(_context.MongoDatabaseConenction)); List <IExecutionChartReport> executionCharts = new List <IExecutionChartReport>() { new MongoExecutionChartReport(new MongoQueryExecution(optionsMock)) }; ChartService chartService = new ChartService(mockDatabaseServiceProvider.Object, null, executionCharts); // Act LetPortal.Portal.Models.Charts.ExecutionChartResponseModel result = await chartService.Execute(new LetPortal.Portal.Entities.Components.Chart { DatabaseOptions = new LetPortal.Portal.Entities.Shared.SharedDatabaseOptions { Query = "{\r\n \"$query\":{\r\n \"apps\":[]\r\n }\r\n}" }, Definitions = new LetPortal.Portal.Entities.Components.ChartDefinitions { ChartTitle = "aaa", ChartType = LetPortal.Portal.Entities.Components.ChartType.VerticalBarChart, MappingProjection = "name=name;value=createdDate;group=name" } }, new LetPortal.Portal.Models.Charts.ExecutionChartRequestModel { ChartId = "asdas", ChartFilterValues = new List <LetPortal.Portal.Models.Charts.ChartFilterValue> { new LetPortal.Portal.Models.Charts.ChartFilterValue { FilterType = LetPortal.Portal.Entities.Components.FilterType.NumberPicker, Name = "timeSpan", IsMultiple = true, Value = "['1000-837076877586810630','10000-737076877586810630']" }, new LetPortal.Portal.Models.Charts.ChartFilterValue { FilterType = LetPortal.Portal.Entities.Components.FilterType.DatePicker, Name = "createdDate", IsMultiple = true, Value = string.Format("['{0}','{1}']", DateTime.UtcNow.AddDays(-1).ToString("o"), DateTime.UtcNow.AddDays(1).ToString("o")) } } }); // Assert Assert.NotEmpty(result.Result); }
public async Task Execution_Chart_Report_Real_Time_In_Sql_Server_Test() { if (!_context.AllowSQLServer) { Assert.True(true); return; } // Arrange Mock <IDatabaseServiceProvider> mockDatabaseServiceProvider = new Mock <IDatabaseServiceProvider>(); mockDatabaseServiceProvider .Setup(a => a.GetOneDatabaseConnectionAsync(It.IsAny <string>())) .Returns(Task.FromResult(_context.SqlServerDatabaseConnection)); List <IExecutionChartReport> executionCharts = new List <IExecutionChartReport>() { new SqlServerExecutionChartReport( new ChartReportQueryBuilder(), new ChartReportProjection(), new SqlServerMapper(_context.MapperOptions), new CSharpMapper()) }; ChartService chartService = new ChartService(mockDatabaseServiceProvider.Object, null, executionCharts); // Act LetPortal.Portal.Models.Charts.ExecutionChartResponseModel result = await chartService.Execute(new LetPortal.Portal.Entities.Components.Chart { DatabaseOptions = new LetPortal.Portal.Entities.Shared.SharedDatabaseOptions { Query = "SELECT name, \"displayName\", \"timeSpan\", \"createdDate\", \"modifiedDate\" FROM \"apps\"" }, Definitions = new LetPortal.Portal.Entities.Components.ChartDefinitions { ChartTitle = "aaa", ChartType = LetPortal.Portal.Entities.Components.ChartType.VerticalBarChart, MappingProjection = "name=name;value=createdDate;group=name" } }, new LetPortal.Portal.Models.Charts.ExecutionChartRequestModel { ChartId = "asdas", ChartFilterValues = new List <LetPortal.Portal.Models.Charts.ChartFilterValue> { new LetPortal.Portal.Models.Charts.ChartFilterValue { FilterType = LetPortal.Portal.Entities.Components.FilterType.NumberPicker, Name = "timeSpan", IsMultiple = true, Value = "['1000-837076877586810630','10000-737076877586810630']" }, new LetPortal.Portal.Models.Charts.ChartFilterValue { FilterType = LetPortal.Portal.Entities.Components.FilterType.DatePicker, Name = "dateCreated", IsMultiple = true, Value = string.Format("['{0}','{1}']", DateTime.UtcNow.AddDays(-1).ToString("o"), DateTime.UtcNow.AddDays(1).ToString("o")) } }, IsRealTime = true, LastRealTimeComparedDate = DateTime.UtcNow.AddDays(-1), RealTimeField = "dateCreated" }); // Assert Assert.NotEmpty(result.Result); }