forked from ddrilling/AsbCloudServer
139 lines
6.1 KiB
C#
139 lines
6.1 KiB
C#
using AsbCloudApp.Data;
|
|
using AsbCloudApp.Data.WITS;
|
|
using AsbCloudApp.Repositories;
|
|
using AsbCloudInfrastructure.Services.Trajectory;
|
|
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
|
|
{
|
|
private Mock<IPlannedTrajectoryRepository> MakePlannedTrajectoryRepositoryMock(IEnumerable<PlannedTrajectoryDto> dateForGetMethod)
|
|
{
|
|
var mock = new Mock<IPlannedTrajectoryRepository>();
|
|
|
|
mock.Setup(r => r.GetAsync(It.IsAny<int>(), It.IsAny<CancellationToken>()))
|
|
.Returns(Task.FromResult(dateForGetMethod));
|
|
|
|
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()
|
|
{
|
|
var plannedTrajectory = new PlannedTrajectoryDto[]
|
|
{
|
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 0d},
|
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 10d},
|
|
new() { AzimuthGeo = 0d, ZenithAngle = 30d, WellboreDepth = 20d},
|
|
new() { AzimuthGeo = 30d, ZenithAngle = 0d, WellboreDepth = 30d},
|
|
new() { AzimuthGeo = 30d, ZenithAngle = 90d, WellboreDepth = 40d},
|
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 50d},
|
|
};
|
|
|
|
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},
|
|
};
|
|
|
|
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]
|
|
public async Task GetTrajectoryAsync_StraigthBore()
|
|
{
|
|
var plannedTrajectory = new PlannedTrajectoryDto[]
|
|
{
|
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 0d},
|
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 0d},
|
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 20d},
|
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 20d},
|
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 30d},
|
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 50d},
|
|
};
|
|
|
|
var factualTrajectory = new Record7Dto[]
|
|
{
|
|
new() { Svyazc = 0, Svyinc = 0, Deptsvym = 0},
|
|
new() { Svyazc = 0, Svyinc = 0, Deptsvym = 0},
|
|
new() { Svyazc = 0, Svyinc = 0, Deptsvym = 20},
|
|
new() { Svyazc = 0, Svyinc = 0, Deptsvym = 20},
|
|
new() { Svyazc = 0, Svyinc = 0, Deptsvym = 30},
|
|
new() { Svyazc = 0, Svyinc = 0, Deptsvym = 50},
|
|
};
|
|
|
|
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);
|
|
|
|
Assert.Equal(0d, lastPointFact.X, 0.1d);
|
|
Assert.Equal(0d, lastPointFact.Y, 0.1d);
|
|
Assert.Equal(50d, lastPointFact.Z, 0.1d);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task GetTrajectoryAsync_Match()
|
|
{
|
|
var plannedTrajectory = new PlannedTrajectoryDto[]
|
|
{
|
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 0d},
|
|
new() { AzimuthGeo = 30d, ZenithAngle = 30d, WellboreDepth = 10d},
|
|
new() { AzimuthGeo = 0d, ZenithAngle = 0d, WellboreDepth = 20d},
|
|
};
|
|
|
|
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},
|
|
};
|
|
|
|
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 lastPointFact = result.Fact!.Last();
|
|
var tolerancePlan = 0.001d;
|
|
var toleranceFact = 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);
|
|
|
|
Assert.InRange(lastPointFact.Z, 10 + toleranceFact, 20 - toleranceFact);
|
|
Assert.InRange(lastPointFact.Y, 0 + toleranceFact, 10 - toleranceFact);
|
|
Assert.InRange(lastPointFact.X, 0 + toleranceFact, 10 - toleranceFact);
|
|
}
|
|
}
|
|
}
|