From 139a66a2c9626d30b5e3ddfecac6ba11f8cfbc4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A1=D1=82=D0=B5=D0=BF=D0=B0=D0=BD=D0=BE=D0=B2=20=D0=94?= =?UTF-8?q?=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Mon, 15 Apr 2024 10:09:07 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=83=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20=D1=84=D0=B8=D0=BA=D1=82?= =?UTF-8?q?=D0=B8=D0=B2=D0=BD=D1=8B=D1=85=20=D1=81=D1=83=D1=82=D0=BE=D1=87?= =?UTF-8?q?=D0=BD=D1=8B=D1=85=20=D0=BE=D1=82=D1=87=D1=91=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/DailyReport/DailyReportService.cs | 3 +-- AsbCloudWebApi.Tests/Services/DailyReportServiceTest.cs | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs index 21fba541..3f498ad9 100644 --- a/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs +++ b/AsbCloudInfrastructure/Services/DailyReport/DailyReportService.cs @@ -177,8 +177,7 @@ public class DailyReportService : IDailyReportService datesRange.To = finishDate; } - result.Count = (int)(Math.Ceiling((datesRange.To - DateTimeOffset.UnixEpoch).TotalDays) - - Math.Floor((datesRange.From - DateTimeOffset.UnixEpoch).TotalDays)); + result.Count = (datesRange.To.Day - DateTimeOffset.UnixEpoch.Day) - (datesRange.From.Day - DateTimeOffset.UnixEpoch.Day); var existingDailyReports = await dailyReportRepository.GetAsync(idWell, request, cancellationToken); diff --git a/AsbCloudWebApi.Tests/Services/DailyReportServiceTest.cs b/AsbCloudWebApi.Tests/Services/DailyReportServiceTest.cs index 38f1959e..90c00957 100644 --- a/AsbCloudWebApi.Tests/Services/DailyReportServiceTest.cs +++ b/AsbCloudWebApi.Tests/Services/DailyReportServiceTest.cs @@ -157,7 +157,7 @@ public class DailyReportServiceTest IdParentCategory = 4001, IdWellSectionType = 1, OperationCategoryName = "Механическое. бурение", - DateStart = new DateTime(2023, 10, 26), + DateStart = new DateTime(2023, 10, 26, 0, 0, 0), DepthStart = 80, DepthEnd = 150, DurationHours = 8, @@ -169,7 +169,7 @@ public class DailyReportServiceTest OperationCategoryName = "Механическое. бурение", IdWellSectionType = 1, IdParentCategory = 4001, - DateStart = new DateTime(2023, 10, 26), + DateStart = new DateTime(2023, 10, 26, 23, 59, 59), DepthStart = 150, DepthEnd = 200, DurationHours = 8, @@ -507,7 +507,7 @@ public class DailyReportServiceTest public async Task GetAsync_ShouldReturn_FictiveDailyReport() { //arrange - var expectedCount = (fakeLastFactWellOperation.DateStart - fakeFirstFactWellOperation.DateStart).TotalDays + 1; + var expectedCount = fakeLastFactWellOperation.DateStart.Day - fakeFirstFactWellOperation.DateStart.Day; //act var result = await dailyReportService.GetAsync(idWell, new FileReportRequest(), CancellationToken.None);