コード例 #1
0
        public async Task CalculateNewLabelsInLabelGroup_WhenReportsDontMeetDistanceThreshold_ShouldAssignDifferentLabels()
        {
            //arrange
            _testData.CalculateNewLabelsInLabelGroup_WhenReportsDontMeetDistanceThreshold.GenerateData().AddToDbContext();
            var distanceThreshold = _testData.CalculateNewLabelsInLabelGroup_WhenReportsDontMeetDistanceThreshold.AdditionalData.KilometerThreshold;
            var group1Label       = _testData.CalculateNewLabelsInLabelGroup_WhenReportsDontMeetDistanceThreshold.AdditionalData.Label;

            //act
            var pointsWithNewLabels = (await _reportLabelingService.CalculateNewLabelsInLabelGroup(group1Label, distanceThreshold * 1000 * 2, null)).ToList();

            //assert
            pointsWithNewLabels.Count().ShouldBe(3);
            pointsWithNewLabels[0].Label.ShouldNotBe(group1Label);
            pointsWithNewLabels[1].Label.ShouldNotBe(group1Label);
            pointsWithNewLabels[2].Label.ShouldNotBe(group1Label);

            pointsWithNewLabels[0].Label.ShouldNotBe(pointsWithNewLabels[1].Label);
            pointsWithNewLabels[1].Label.ShouldNotBe(pointsWithNewLabels[2].Label);
            pointsWithNewLabels[2].Label.ShouldNotBe(pointsWithNewLabels[0].Label);
        }
コード例 #2
0
ファイル: AlertService.cs プロジェクト: KevinTss/nyss
        private async Task RecalculateAlert(Report report, AlertRule alertRule)
        {
            var pointsWithLabels = await _reportLabelingService.CalculateNewLabelsInLabelGroup(report.ReportGroupLabel, alertRule.KilometersThreshold.Value * 1000 * 2, report.Id);

            await _reportLabelingService.UpdateLabelsInDatabaseDirect(pointsWithLabels);
        }