public void TestGetQueryResultLatLon() { Mock <IMeasurementDao> dao = new Mock <IMeasurementDao>(MockBehavior.Strict); Task <double[]> result = new Task <double[]>(() => new double[] { 2.3, 4.33 }); result.RunSynchronously(); dao.Setup(d => d.GetQueryResult( It.IsAny <DateTime>(), It.IsAny <DateTime>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <List <Station> >(), It.IsAny <decimal>(), It.IsAny <decimal>(), It.IsAny <int>() )).Returns(result); MeasurementManager m = new MeasurementManager(dao.Object, null, null); double[] res = m.GetQueryResult(DateTime.Now, DateTime.Now, 0, 0, 0, null, 0, 0, 0).Result; Assert.AreEqual(result.Result, res); }
private async void ExecuteApplyAnalysis() { string LiveChartTitle = ""; Console.WriteLine("Applying"); Console.WriteLine("Start/End: " + StartDate + "/" + EndDate); Console.WriteLine("Type/Group/Reduce: " + SelectedTargetType + "/" + SelectedGroupingType + "/" + SelectedReduceType); int measurementTypeId = 0; switch (this.SelectedTargetType) { case TargetType.Air_Preassure: measurementTypeId = 2; LiveChartTitle = "Air Pressure"; break; case TargetType.Humidity: measurementTypeId = 4; LiveChartTitle = "Humidity"; break; case TargetType.Rain: measurementTypeId = 3; LiveChartTitle = "Rain"; break; case TargetType.Temperature: measurementTypeId = 1; LiveChartTitle = "Temperature"; break; case TargetType.Wind: measurementTypeId = 5; LiveChartTitle = "Wind"; break; case TargetType.Wind_direction: measurementTypeId = 6; LiveChartTitle = "Wind Direction"; break; } int reductionTypeId = 0; switch (this.SelectedReduceType) { case ReduceType.Average: reductionTypeId = 0; break; case ReduceType.Minimum: reductionTypeId = 1; break; case ReduceType.Maximum: reductionTypeId = 2; break; case ReduceType.Sum: reductionTypeId = 3; break; } int groupingTypeId = 0; switch (this.SelectedGroupingType) { case GroupingType.Day: groupingTypeId = 0; break; case GroupingType.Week: groupingTypeId = 1; break; case GroupingType.Month: groupingTypeId = 2; break; case GroupingType.Year: groupingTypeId = 3; break; case GroupingType.Hour: groupingTypeId = 4; break; } double[] result = null; if (Longitude != 0 && Latitude != 0 && Radius != 0) { notifierManager.ShowInformation("Fetching results based on coordinates..."); result = await measurementManager.GetQueryResult(StartDate, EndDate, measurementTypeId, reductionTypeId, groupingTypeId, this.selectedStations.ToList(), Latitude, Longitude, Radius); } else { if (SelectedCommunity != null && SelectedCommunity.CommunityId != -1) { notifierManager.ShowInformation("Fetching results based on the selected community..."); result = await measurementManager.GetQueryResult(StartDate, EndDate, measurementTypeId, reductionTypeId, groupingTypeId, this.selectedStations.ToList(), this.SelectedCommunity); } else if (SelectedDistrict != null && SelectedDistrict.DistrictId != -1) { notifierManager.ShowInformation("Fetching results based on the selected district..."); result = await measurementManager.GetQueryResult(StartDate, EndDate, measurementTypeId, reductionTypeId, groupingTypeId, this.selectedStations.ToList(), this.SelectedDistrict); } else if (SelectedProvince != null && SelectedProvince.ProvinceId != -1) { if (SelectedProvince.ProvinceId == -2) { notifierManager.ShowInformation("Fetching results based on every region..."); result = await measurementManager.GetQueryResult(StartDate, EndDate, measurementTypeId, reductionTypeId, groupingTypeId, this.selectedStations.ToList()); } else { notifierManager.ShowInformation("Fetching results based on the selected province..."); result = await measurementManager.GetQueryResult(StartDate, EndDate, measurementTypeId, reductionTypeId, groupingTypeId, this.selectedStations.ToList(), this.SelectedProvince); } } else { notifierManager.ShowError("Please select a region or enter coordinates to filter the location!"); return; } } AggregateViewModel aggregateViewModel = new AggregateViewModel(); aggregateViewModel.AddToCollection(LiveChartTitle, 1, result); MetroWindow aggregateWindow = new MetroWindow { Title = LiveChartTitle + " Chart Window" }; AggregateView aggregateView = new AggregateView { DataContext = aggregateViewModel }; aggregateWindow.Content = aggregateView; aggregateWindow.Show(); foreach (double d in result) { Console.WriteLine(d); } }