Поправлены автотесты

This commit is contained in:
Olga Nemt 2023-05-31 10:17:54 +05:00
parent 5e509a1cb7
commit 03949ed625

View File

@ -13,8 +13,9 @@ namespace AsbCloudWebApi.Tests.ServicesTests
{ {
public class TrajectoryVisualizationServiceTest public class TrajectoryVisualizationServiceTest
{ {
private Mock<T> MakeTrajectoryRepositoryMock<T>(IEnumerable<TrajectoryGeoFactDto> dateForGetMethod) private Mock<T> MakeTrajectoryRepositoryMock<T, V>(IEnumerable<V> dateForGetMethod)
where T : class, ITrajectoryPlanRepository where V : TrajectoryGeoDto
where T : class, ITrajectoryRepository<V>
{ {
var mock = new Mock<T>(); var mock = new Mock<T>();
@ -27,25 +28,25 @@ namespace AsbCloudWebApi.Tests.ServicesTests
[Fact] [Fact]
public async Task GetTrajectoryAsync_SameCounts() public async Task GetTrajectoryAsync_SameCounts()
{ {
var plannedTrajectory = new TrajectoryGeoFactDto[] var plannedTrajectory = new TrajectoryGeoPlanDto[]
{ {
new(0d, 0d, 0d), new TrajectoryGeoPlanDto() { WellboreDepth = 0d, ZenithAngle = 0d, AzimuthGeo = 0d },
new(0d, 0d, 10d), new TrajectoryGeoPlanDto() { WellboreDepth = 0d, ZenithAngle = 0d, AzimuthGeo = 10d },
new(0d, 30d, 20d), new TrajectoryGeoPlanDto() { WellboreDepth = 0d, ZenithAngle = 30d, AzimuthGeo = 20d },
new(30d, 0d, 30d), new TrajectoryGeoPlanDto() { WellboreDepth = 30d, ZenithAngle = 0d, AzimuthGeo = 30d },
new(30d, 90d, 40d), new TrajectoryGeoPlanDto() { WellboreDepth = 30d, ZenithAngle = 90d, AzimuthGeo = 40d },
new(0d, 0d, 50d), new TrajectoryGeoPlanDto() { WellboreDepth = 0d, ZenithAngle = 0d, AzimuthGeo = 50d },
}; };
var actualTrajectory = new TrajectoryGeoFactDto[] var actualTrajectory = new TrajectoryGeoFactDto[]
{ {
new(0, 0, 0), new TrajectoryGeoFactDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
new(30,30,10), new TrajectoryGeoFactDto() { WellboreDepth = 30, ZenithAngle = 30, AzimuthGeo = 10 },
new(0, 0, 20), new TrajectoryGeoFactDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 20 },
}; };
var mockPlan = MakeTrajectoryRepositoryMock<ITrajectoryPlanRepository>(plannedTrajectory); var mockPlan = MakeTrajectoryRepositoryMock<ITrajectoryPlanRepository, TrajectoryGeoPlanDto>(plannedTrajectory);
var mockFact = MakeTrajectoryRepositoryMock<ITrajectoryFactRepository>(actualTrajectory); var mockFact = MakeTrajectoryRepositoryMock<ITrajectoryFactRepository, TrajectoryGeoFactDto>(actualTrajectory);
var service = new TrajectoryService(mockPlan.Object, mockFact.Object); var service = new TrajectoryService(mockPlan.Object, mockFact.Object);
var result = await service.GetTrajectoryCartesianAsync(1, CancellationToken.None); var result = await service.GetTrajectoryCartesianAsync(1, CancellationToken.None);
Assert.Equal(plannedTrajectory.Length, result.Plan?.Count()); Assert.Equal(plannedTrajectory.Length, result.Plan?.Count());
@ -55,18 +56,28 @@ namespace AsbCloudWebApi.Tests.ServicesTests
[Fact] [Fact]
public async Task GetTrajectoryAsync_StraigthBore() public async Task GetTrajectoryAsync_StraigthBore()
{ {
var trajectory = new TrajectoryGeoFactDto[] var plannedTrajectory = new TrajectoryGeoPlanDto[]
{ {
new(0, 0, 0), new TrajectoryGeoPlanDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
new(0, 0, 0), new TrajectoryGeoPlanDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
new(20, 0, 0), new TrajectoryGeoPlanDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
new(20, 0, 0), new TrajectoryGeoPlanDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
new(30, 0, 0), new TrajectoryGeoPlanDto() { WellboreDepth = 30, ZenithAngle = 0, AzimuthGeo = 0 },
new(50, 0, 0), new TrajectoryGeoPlanDto() { WellboreDepth = 50, ZenithAngle = 0, AzimuthGeo = 0 },
}; };
var mockPlan = MakeTrajectoryRepositoryMock<ITrajectoryPlanRepository>(trajectory); var actualTrajectory = new TrajectoryGeoFactDto[]
var mockFact = MakeTrajectoryRepositoryMock<ITrajectoryFactRepository>(trajectory); {
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);
var service = new TrajectoryService(mockPlan.Object, mockFact.Object); var service = new TrajectoryService(mockPlan.Object, mockFact.Object);
var result = await service.GetTrajectoryCartesianAsync(1, CancellationToken.None); var result = await service.GetTrajectoryCartesianAsync(1, CancellationToken.None);
var lastPointPlan = result.Plan!.Last(); var lastPointPlan = result.Plan!.Last();
@ -84,15 +95,22 @@ namespace AsbCloudWebApi.Tests.ServicesTests
[Fact] [Fact]
public async Task GetTrajectoryAsync_Match() public async Task GetTrajectoryAsync_Match()
{ {
var trajectory = new TrajectoryGeoFactDto[] var plannedTrajectory = new TrajectoryGeoPlanDto[]
{ {
new(0, 0, 0), new TrajectoryGeoPlanDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
new(10, 30, 30), new TrajectoryGeoPlanDto() { WellboreDepth = 10, ZenithAngle = 30, AzimuthGeo = 30 },
new(20, 0, 0), new TrajectoryGeoPlanDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
}; };
var mockPlanned = MakeTrajectoryRepositoryMock<ITrajectoryPlanRepository>(trajectory); var actualTrajectory = new TrajectoryGeoFactDto[]
var mockFactual = MakeTrajectoryRepositoryMock<ITrajectoryFactRepository>(trajectory); {
new TrajectoryGeoFactDto() { WellboreDepth = 0, ZenithAngle = 0, AzimuthGeo = 0 },
new TrajectoryGeoFactDto() { WellboreDepth = 10, ZenithAngle = 30, AzimuthGeo = 30 },
new TrajectoryGeoFactDto() { WellboreDepth = 20, ZenithAngle = 0, AzimuthGeo = 0 },
};
var mockPlanned = MakeTrajectoryRepositoryMock<ITrajectoryPlanRepository, TrajectoryGeoPlanDto>(plannedTrajectory);
var mockFactual = MakeTrajectoryRepositoryMock<ITrajectoryFactRepository, TrajectoryGeoFactDto>(actualTrajectory);
var service = new TrajectoryService(mockPlanned.Object, mockFactual.Object); var service = new TrajectoryService(mockPlanned.Object, mockFactual.Object);
var result = await service.GetTrajectoryCartesianAsync(1, CancellationToken.None); var result = await service.GetTrajectoryCartesianAsync(1, CancellationToken.None);
var lastPointPlan = result.Plan!.Last(); var lastPointPlan = result.Plan!.Last();