From d55b9b41386e2506b914b0c0ec25d69a43b4e569 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Thu, 29 Feb 2024 13:45:28 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=B0=D0=B4=D0=B5=D0=BD=D0=B8=D1=8F=20=D0=B2=20WellOperationEx?= =?UTF-8?q?portServiceTest=20(=D1=81=D1=80=D0=B0=D0=B2=D0=BD=D0=B8=D0=B2?= =?UTF-8?q?=D0=B0=D0=BB=D0=B8=D1=81=D1=8C=20=D0=B4=D0=B0=D1=82=D1=8B=20?= =?UTF-8?q?=D1=81=D0=BE=20=D1=81=D0=BC=D0=B5=D1=89=D0=B5=D0=BD=D0=B8=D0=B5?= =?UTF-8?q?=D0=BC=20=D0=B8=20=D0=B1=D0=B5=D0=B7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WellOperationExportServiceTest.cs | 102 ++++++++++-------- 1 file changed, 55 insertions(+), 47 deletions(-) diff --git a/AsbCloudWebApi.Tests/Services/WellOperationExport/WellOperationExportServiceTest.cs b/AsbCloudWebApi.Tests/Services/WellOperationExport/WellOperationExportServiceTest.cs index 0c8523c4..ad3d3895 100644 --- a/AsbCloudWebApi.Tests/Services/WellOperationExport/WellOperationExportServiceTest.cs +++ b/AsbCloudWebApi.Tests/Services/WellOperationExport/WellOperationExportServiceTest.cs @@ -5,11 +5,9 @@ using AsbCloudApp.Requests; using AsbCloudApp.Services; using AsbCloudApp.Services.WellOperationImport; using AsbCloudDb.Model; -using AsbCloudInfrastructure.Repository; using AsbCloudInfrastructure.Services.WellOperationImport; using AsbCloudInfrastructure.Services.WellOperationImport.FileParser; using NSubstitute; -using SignalRSwaggerGen.Enums; using System; using System.Collections.Generic; using System.Linq; @@ -34,41 +32,6 @@ namespace AsbCloudWebApi.Tests.Services.WellOperationExport private WellOperationImportService wellOperationImportService; private IWellOperationExcelParser wellOperationDefaultExcelParser; - private readonly WellOperationDto[] operations = new WellOperationDto[2] { - new WellOperationDto() { - Id = 5, - IdWell = idWell, - IdUser = 1, - IdType = 0, - IdWellSectionType = 1, - WellSectionTypeName = "1", - IdCategory = 1, - CategoryName = "1", - CategoryInfo = "CategoryInfo 1", - DepthStart = 10, - DepthEnd = 20, - DateStart = GetDate(days: 0), - DurationHours = 10, - Comment = "Комментарий 1", - }, - new WellOperationDto() { - Id = 6, - IdWell = idWell, - IdUser = 1, - IdType = 0, - IdWellSectionType = 2, - WellSectionTypeName = "2", - IdCategory = 2, - CategoryName = "2", - CategoryInfo = "CategoryInfo 2", - DepthStart = 20, - DepthEnd = 30, - DateStart = GetDate(days: 1), - DurationHours = 20, - Comment = "Комментарий 2", - } - }; - private readonly WellSectionTypeDto[] sectionTypes = new WellSectionTypeDto[2] { new WellSectionTypeDto() @@ -106,12 +69,6 @@ namespace AsbCloudWebApi.Tests.Services.WellOperationExport }; private readonly ITestOutputHelper output; - private static DateTime GetDate(int days) - { - var date = DateTime.Now.AddDays(days); - return new DateTime(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second); - } - public WellOperationExportServiceTest(ITestOutputHelper output) { wellService = Substitute.For(); @@ -123,17 +80,20 @@ namespace AsbCloudWebApi.Tests.Services.WellOperationExport wellOperationImportService = new WellOperationImportService(wellService, wellOperationRepository, wellOperationCategoryRepository); wellOperationDefaultExcelParser = new WellOperationDefaultExcelParser(); this.output = output; + + wellService.GetTimezone(idWell).Returns(new SimpleTimezoneDto() + { + Hours = 5 + }); } [Fact] public async Task Check_Exported_WellOperations_With_Operations_In_Db() { - wellService.GetTimezone(idWell).Returns(new SimpleTimezoneDto() - { - Hours = 5 - }); + var operations = getOperations(); var localOperations = operations.ToArray(); + foreach (var operation in localOperations) operation.Id = 0; @@ -161,6 +121,7 @@ namespace AsbCloudWebApi.Tests.Services.WellOperationExport public void TestDataContainsNotDefaultProps() { var initOk = true; + var operations = getOperations(); for (int i = 0; i < operations.Length; i++) { var operation = operations[i]; @@ -204,5 +165,52 @@ namespace AsbCloudWebApi.Tests.Services.WellOperationExport yield return prop.Name; } } + + private WellOperationDto[] getOperations() + { + + var timezone = wellService.GetTimezone(idWell); + + DateTimeOffset GetDate(int days) + { + var date = DateTimeOffset.UtcNow.AddDays(days); + return new DateTimeOffset(date.Year, date.Month, date.Day, date.Hour, date.Minute, date.Second, TimeSpan.FromHours(timezone.Hours)); + } + + return new WellOperationDto[2] { + new WellOperationDto() { + Id = 5, + IdWell = idWell, + IdUser = 1, + IdType = 0, + IdWellSectionType = 1, + WellSectionTypeName = "1", + IdCategory = 1, + CategoryName = "1", + CategoryInfo = "CategoryInfo 1", + DepthStart = 10, + DepthEnd = 20, + DateStart = GetDate(days: 0), + DurationHours = 10, + Comment = "Комментарий 1", + }, + new WellOperationDto() { + Id = 6, + IdWell = idWell, + IdUser = 1, + IdType = 0, + IdWellSectionType = 2, + WellSectionTypeName = "2", + IdCategory = 2, + CategoryName = "2", + CategoryInfo = "CategoryInfo 2", + DepthStart = 20, + DepthEnd = 30, + DateStart = GetDate(days: 1), + DurationHours = 20, + Comment = "Комментарий 2", + } + }; + } } }