public async Task UpdateLabelsInDatabaseDirect_NyssContextShouldReceiveExpectedSqlCommands() { //arrange var label1 = Guid.Parse("9ce11e66-4a73-471e-8062-c1c197949b94"); var label2 = Guid.Parse("e3081ed4-e61e-47c3-b620-0e679a5c9e3d"); var pointWithLabels = new List <(int, Guid)> { (1, label1), (2, label1), (3, label2), (4, label2) }; //act await _reportLabelingService.UpdateLabelsInDatabaseDirect(pointWithLabels); //assert await _nyssContextMock.Received(2).ExecuteSqlInterpolatedAsync(Arg.Any <FormattableString>()); await _nyssContextMock.Received(1).ExecuteSqlInterpolatedAsync(Arg.Is <FormattableString>(x => x.ToString() == $"UPDATE nyss.Reports SET ReportGroupLabel={label1} WHERE Id IN (1, 2)")); await _nyssContextMock.Received(1).ExecuteSqlInterpolatedAsync(Arg.Is <FormattableString>(x => x.ToString() == $"UPDATE nyss.Reports SET ReportGroupLabel={label2} WHERE Id IN (3, 4)")); }
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); }