2023-02-15 13:35:18 +05:00
|
|
|
|
using AsbCloudApp.Data;
|
2023-05-10 11:31:40 +05:00
|
|
|
|
using AsbCloudApp.Data.WITS;
|
2023-02-15 13:35:18 +05:00
|
|
|
|
using AsbCloudApp.Repositories;
|
2023-02-21 10:19:07 +05:00
|
|
|
|
using AsbCloudInfrastructure.Services.Trajectory;
|
2023-02-15 13:35:18 +05:00
|
|
|
|
using Moq;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudWebApi.Tests.ServicesTests
|
|
|
|
|
{
|
|
|
|
|
public class TrajectoryVisualizationServiceTest
|
|
|
|
|
{
|
2023-05-31 10:17:54 +05:00
|
|
|
|
private Mock<T> MakeTrajectoryRepositoryMock<T, V>(IEnumerable<V> dateForGetMethod)
|
|
|
|
|
where V : TrajectoryGeoDto
|
|
|
|
|
where T : class, ITrajectoryRepository<V>
|
2023-02-15 13:35:18 +05:00
|
|
|
|
{
|
2023-05-11 15:36:49 +05:00
|
|
|
|
var mock = new Mock<T>();
|
2023-02-15 13:35:18 +05:00
|
|
|
|
|
2023-05-30 11:21:07 +05:00
|
|
|
|
mock.Setup(r => r.GetAsync(It.IsAny<int>(), It.IsAny<CancellationToken>()))
|
2023-05-10 11:31:40 +05:00
|
|
|
|
.Returns(Task.FromResult(dateForGetMethod));
|
|
|
|
|
|
|
|
|
|
return mock;
|
|
|
|
|
}
|
|
|
|
|
|
2023-02-15 13:35:18 +05:00
|
|
|
|
[Fact]
|
|
|
|
|
public async Task GetTrajectoryAsync_SameCounts()
|
|
|
|
|
{
|
2023-05-31 10:17:54 +05:00
|
|
|
|
var plannedTrajectory = new TrajectoryGeoPlanDto[]
|
2023-02-15 13:35:18 +05:00
|
|
|
|
{
|
2023-05-31 10:17:54 +05:00
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0d, ZenithAngle = 0d, AzimuthGeo = 0d },
|
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0d, ZenithAngle = 0d, AzimuthGeo = 10d },
|
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0d, ZenithAngle = 30d, AzimuthGeo = 20d },
|
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 30d, ZenithAngle = 0d, AzimuthGeo = 30d },
|
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 30d, ZenithAngle = 90d, AzimuthGeo = 40d },
|
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0d, ZenithAngle = 0d, AzimuthGeo = 50d },
|
2023-02-15 13:35:18 +05:00
|
|
|
|
};
|
|
|
|
|
|
2023-05-30 11:21:07 +05:00
|
|
|
|
var actualTrajectory = new TrajectoryGeoFactDto[]
|
2023-05-10 11:31:40 +05:00
|
|
|
|
{
|
2023-05-31 10:17:54 +05:00
|
|
|
|
new TrajectoryGeoFactDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
new TrajectoryGeoFactDto() { WellboreDepth = 30, ZenithAngle = 30, AzimuthGeo = 10 },
|
|
|
|
|
new TrajectoryGeoFactDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 20 },
|
2023-05-10 11:31:40 +05:00
|
|
|
|
};
|
2023-02-15 13:35:18 +05:00
|
|
|
|
|
2023-05-31 10:17:54 +05:00
|
|
|
|
var mockPlan = MakeTrajectoryRepositoryMock<ITrajectoryPlanRepository, TrajectoryGeoPlanDto>(plannedTrajectory);
|
|
|
|
|
var mockFact = MakeTrajectoryRepositoryMock<ITrajectoryFactRepository, TrajectoryGeoFactDto>(actualTrajectory);
|
2023-05-30 11:21:07 +05:00
|
|
|
|
var service = new TrajectoryService(mockPlan.Object, mockFact.Object);
|
|
|
|
|
var result = await service.GetTrajectoryCartesianAsync(1, CancellationToken.None);
|
2023-05-10 11:31:40 +05:00
|
|
|
|
Assert.Equal(plannedTrajectory.Length, result.Plan?.Count());
|
|
|
|
|
Assert.Equal(actualTrajectory.Length, result.Fact?.Count());
|
2023-02-15 13:35:18 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
2023-06-30 17:57:00 +05:00
|
|
|
|
public async Task GetTrajectoryAsync_StraightBore()
|
2023-02-15 13:35:18 +05:00
|
|
|
|
{
|
2023-05-31 10:17:54 +05:00
|
|
|
|
var plannedTrajectory = new TrajectoryGeoPlanDto[]
|
2023-02-15 13:35:18 +05:00
|
|
|
|
{
|
2023-05-31 10:17:54 +05:00
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 30, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 50, ZenithAngle = 0, AzimuthGeo = 0 },
|
2023-05-10 11:31:40 +05:00
|
|
|
|
};
|
|
|
|
|
|
2023-05-31 10:17:54 +05:00
|
|
|
|
var actualTrajectory = new TrajectoryGeoFactDto[]
|
|
|
|
|
{
|
|
|
|
|
new TrajectoryGeoFactDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
new TrajectoryGeoFactDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
new TrajectoryGeoFactDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
new TrajectoryGeoFactDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
new TrajectoryGeoFactDto() { WellboreDepth = 30, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
new TrajectoryGeoFactDto() { WellboreDepth = 50, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var mockPlan = MakeTrajectoryRepositoryMock<ITrajectoryPlanRepository, TrajectoryGeoPlanDto>(plannedTrajectory);
|
|
|
|
|
var mockFact = MakeTrajectoryRepositoryMock<ITrajectoryFactRepository, TrajectoryGeoFactDto>(actualTrajectory);
|
2023-05-30 11:21:07 +05:00
|
|
|
|
var service = new TrajectoryService(mockPlan.Object, mockFact.Object);
|
|
|
|
|
var result = await service.GetTrajectoryCartesianAsync(1, CancellationToken.None);
|
2023-05-10 11:31:40 +05:00
|
|
|
|
var lastPointPlan = result.Plan!.Last();
|
|
|
|
|
var lastPointFact = result.Fact!.Last();
|
2023-02-15 13:35:18 +05:00
|
|
|
|
|
2023-05-10 11:31:40 +05:00
|
|
|
|
Assert.Equal(0d, lastPointPlan.X, 0.1d);
|
|
|
|
|
Assert.Equal(0d, lastPointPlan.Y, 0.1d);
|
|
|
|
|
Assert.Equal(50d, lastPointPlan.Z, 0.1d);
|
2023-05-10 15:05:05 +05:00
|
|
|
|
|
|
|
|
|
Assert.Equal(0d, lastPointFact.X, 0.1d);
|
|
|
|
|
Assert.Equal(0d, lastPointFact.Y, 0.1d);
|
|
|
|
|
Assert.Equal(50d, lastPointFact.Z, 0.1d);
|
2023-02-15 13:35:18 +05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public async Task GetTrajectoryAsync_Match()
|
|
|
|
|
{
|
2023-05-31 10:17:54 +05:00
|
|
|
|
var plannedTrajectory = new TrajectoryGeoPlanDto[]
|
|
|
|
|
{
|
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 10, ZenithAngle = 30, AzimuthGeo = 30 },
|
|
|
|
|
new TrajectoryGeoPlanDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var actualTrajectory = new TrajectoryGeoFactDto[]
|
2023-02-15 13:35:18 +05:00
|
|
|
|
{
|
2023-05-31 10:17:54 +05:00
|
|
|
|
new TrajectoryGeoFactDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
|
|
|
|
|
new TrajectoryGeoFactDto() { WellboreDepth = 10, ZenithAngle = 30, AzimuthGeo = 30 },
|
|
|
|
|
new TrajectoryGeoFactDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
|
2023-05-10 11:31:40 +05:00
|
|
|
|
};
|
|
|
|
|
|
2023-05-31 10:17:54 +05:00
|
|
|
|
var mockPlanned = MakeTrajectoryRepositoryMock<ITrajectoryPlanRepository, TrajectoryGeoPlanDto>(plannedTrajectory);
|
|
|
|
|
var mockFactual = MakeTrajectoryRepositoryMock<ITrajectoryFactRepository, TrajectoryGeoFactDto>(actualTrajectory);
|
2023-05-30 11:21:07 +05:00
|
|
|
|
var service = new TrajectoryService(mockPlanned.Object, mockFactual.Object);
|
|
|
|
|
var result = await service.GetTrajectoryCartesianAsync(1, CancellationToken.None);
|
2023-05-10 11:31:40 +05:00
|
|
|
|
var lastPointPlan = result.Plan!.Last();
|
2023-05-10 15:05:05 +05:00
|
|
|
|
var lastPointFact = result.Fact!.Last();
|
2023-05-10 11:31:40 +05:00
|
|
|
|
var tolerancePlan = 0.001d;
|
2023-05-10 15:05:05 +05:00
|
|
|
|
var toleranceFact = 0.001d;
|
2023-02-15 13:35:18 +05:00
|
|
|
|
|
2023-05-10 11:31:40 +05:00
|
|
|
|
Assert.InRange(lastPointPlan.Z, 10 + tolerancePlan, 20 - tolerancePlan);
|
|
|
|
|
Assert.InRange(lastPointPlan.Y, 0 + tolerancePlan, 10 - tolerancePlan);
|
|
|
|
|
Assert.InRange(lastPointPlan.X, 0 + tolerancePlan, 10 - tolerancePlan);
|
2023-05-10 15:05:05 +05:00
|
|
|
|
|
|
|
|
|
Assert.InRange(lastPointFact.Z, 10 + toleranceFact, 20 - toleranceFact);
|
|
|
|
|
Assert.InRange(lastPointFact.Y, 0 + toleranceFact, 10 - toleranceFact);
|
|
|
|
|
Assert.InRange(lastPointFact.X, 0 + toleranceFact, 10 - toleranceFact);
|
2023-02-15 13:35:18 +05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|