From e1228ef6bf08554bd9945cdbf040f2e5a5fdedb8 Mon Sep 17 00:00:00 2001 From: Olga Nemt Date: Wed, 10 May 2023 11:31:40 +0500 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D0=BF=D1=80=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D1=8E=D0=BD=D0=B8=D1=82-=D1=82=D0=B5?= =?UTF-8?q?=D1=81=D1=82=D1=8B=20=D0=B4=D0=BB=D1=8F=20=D0=BF=D0=BB=D0=B0?= =?UTF-8?q?=D0=BD=D0=BE=D0=B2=D0=BE=D0=B9=20=D1=82=D1=80=D0=B0=D0=B5=D0=BA?= =?UTF-8?q?=D1=82=D0=BE=D1=80=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../TrajectoryVisualizationServiceTest.cs | 74 ++++++++++++++----- 1 file changed, 55 insertions(+), 19 deletions(-) diff --git a/AsbCloudWebApi.Tests/ServicesTests/TrajectoryVisualizationServiceTest.cs b/AsbCloudWebApi.Tests/ServicesTests/TrajectoryVisualizationServiceTest.cs index b8d40a3b..30bcf172 100644 --- a/AsbCloudWebApi.Tests/ServicesTests/TrajectoryVisualizationServiceTest.cs +++ b/AsbCloudWebApi.Tests/ServicesTests/TrajectoryVisualizationServiceTest.cs @@ -1,4 +1,5 @@ using AsbCloudApp.Data; +using AsbCloudApp.Data.WITS; using AsbCloudApp.Repositories; using AsbCloudInfrastructure.Services; using AsbCloudInfrastructure.Services.Trajectory; @@ -24,6 +25,16 @@ namespace AsbCloudWebApi.Tests.ServicesTests return mock; } + private Mock MakeFactualTrajectoryRepositoryMock(IEnumerable dateForGetMethod) + { + var mock = new Mock(); + + mock.Setup(r => r.GetAsync(It.IsAny(), It.IsAny())) + .Returns(Task.FromResult(dateForGetMethod)); + + return mock; + } + [Fact] public async Task GetTrajectoryAsync_SameCounts() { @@ -37,11 +48,19 @@ namespace AsbCloudWebApi.Tests.ServicesTests new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 50d}, }; - var mock = MakePlannedTrajectoryRepositoryMock(plannedTrajectory); - //var service = new TrajectoryVisualizationService(mock.Object); - //ar result = await service.GetTrajectoryAsync(1, CancellationToken.None); + var actualTrajectory = new Record7Dto[] + { + new() { Svyazc = 0, Svyinc = 0, Deptsvym = 0}, + new() { Svyazc = 30, Svyinc = 30, Deptsvym = 10}, + new() { Svyazc = 0, Svyinc = 0, Deptsvym = 20}, + }; - //Assert.Equal(plannedTrajectory.Length, result.Count()); + var mockPlan = MakePlannedTrajectoryRepositoryMock(plannedTrajectory); + var mockFact = MakeFactualTrajectoryRepositoryMock(actualTrajectory); + var service = new TrajectoryVisualizationService(mockPlan.Object, mockFact.Object); + var result = await service.GetTrajectoryAsync(1, CancellationToken.None); + Assert.Equal(plannedTrajectory.Length, result.Plan?.Count()); + Assert.Equal(actualTrajectory.Length, result.Fact?.Count()); } [Fact] @@ -57,14 +76,23 @@ namespace AsbCloudWebApi.Tests.ServicesTests new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 50d}, }; - var mock = MakePlannedTrajectoryRepositoryMock(plannedTrajectory); - //var service = new TrajectoryVisualizationService(mock.Object); - //var result = await service.GetTrajectoryAsync(1, CancellationToken.None); - //var lastPoint = result.Last(); + var factualTrajectory = new Record7Dto[] + { + new() { Svyazc = 0, Svyinc = 0, Deptsvym = 0}, + new() { Svyazc = 30, Svyinc = 30, Deptsvym = 10}, + new() { Svyazc = 0, Svyinc = 0, Deptsvym = 20}, + }; - //Assert.Equal(0d, lastPoint.X, 0.1d); - //Assert.Equal(0d, lastPoint.Y, 0.1d); - //Assert.Equal(50d, lastPoint.Z, 0.1d); + var mockPlan = MakePlannedTrajectoryRepositoryMock(plannedTrajectory); + var mockFact = MakeFactualTrajectoryRepositoryMock(factualTrajectory); + var service = new TrajectoryVisualizationService(mockPlan.Object, mockFact.Object); + var result = await service.GetTrajectoryAsync(1, CancellationToken.None); + var lastPointPlan = result.Plan!.Last(); + var lastPointFact = result.Fact!.Last(); + + Assert.Equal(0d, lastPointPlan.X, 0.1d); + Assert.Equal(0d, lastPointPlan.Y, 0.1d); + Assert.Equal(50d, lastPointPlan.Z, 0.1d); } [Fact] @@ -77,15 +105,23 @@ namespace AsbCloudWebApi.Tests.ServicesTests new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 20d}, }; - var mock = MakePlannedTrajectoryRepositoryMock(plannedTrajectory); - //var service = new TrajectoryVisualizationService(mock.Object); - //var result = await service.GetTrajectoryAsync(1, CancellationToken.None); - //var lastPoint = result.Last(); - //var tolerance = 0.001d; + var factualTrajectory = new Record7Dto[] + { + new() { Svyazc = 0, Svyinc = 0, Deptsvym = 0}, + new() { Svyazc = 30, Svyinc = 30, Deptsvym = 10}, + new() { Svyazc = 0, Svyinc = 0, Deptsvym = 20}, + }; - //Assert.InRange(lastPoint.Z, 10 + tolerance, 20 - tolerance); - //Assert.InRange(lastPoint.Y, 0 + tolerance, 10 - tolerance); - //Assert.InRange(lastPoint.X, 0 + tolerance, 10 - tolerance); + var mockPlanned = MakePlannedTrajectoryRepositoryMock(plannedTrajectory); + var mockFactual = MakeFactualTrajectoryRepositoryMock(factualTrajectory); + var service = new TrajectoryVisualizationService(mockPlanned.Object, mockFactual.Object); + var result = await service.GetTrajectoryAsync(1, CancellationToken.None); + var lastPointPlan = result.Plan!.Last(); + var tolerancePlan = 0.001d; + + Assert.InRange(lastPointPlan.Z, 10 + tolerancePlan, 20 - tolerancePlan); + Assert.InRange(lastPointPlan.Y, 0 + tolerancePlan, 10 - tolerancePlan); + Assert.InRange(lastPointPlan.X, 0 + tolerancePlan, 10 - tolerancePlan); } } }