forked from ddrilling/AsbCloudServer
Поправлены юнит-тесты для плановой траектории
This commit is contained in:
parent
83fcf738b9
commit
e1228ef6bf
@ -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<IFactualTrajectoryRepository> MakeFactualTrajectoryRepositoryMock(IEnumerable<Record7Dto> dateForGetMethod)
|
||||
{
|
||||
var mock = new Mock<IFactualTrajectoryRepository>();
|
||||
|
||||
mock.Setup(r => r.GetAsync(It.IsAny<int>(), It.IsAny<CancellationToken>()))
|
||||
.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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user