DD.WellWorkover.Cloud/AsbCloudInfrastructure.Tests/Services/Trajectory/TrajectoryExportTest.cs

129 lines
4.7 KiB
C#
Raw Normal View History

using AsbCloudApp.Data.Trajectory;
2023-11-28 15:54:47 +05:00
using AsbCloudApp.Repositories;
using AsbCloudApp.Services;
using AsbCloudInfrastructure.Services.Trajectory.Export;
using NSubstitute;
using System;
using System.Threading;
using System.Threading.Tasks;
using AsbCloudApp.Requests.ExportOptions;
2023-11-28 15:54:47 +05:00
using Xunit;
2024-08-19 10:57:31 +05:00
namespace AsbCloudInfrastructure.Tests.Services.Trajectory;
2024-08-19 10:01:07 +05:00
public class TrajectoryExportTest
2023-11-28 15:54:47 +05:00
{
2024-08-19 10:01:07 +05:00
private const int idWell = 4;
2024-08-19 10:57:31 +05:00
2024-08-19 10:01:07 +05:00
private IWellService wellService;
private readonly ITrajectoryEditableRepository<TrajectoryGeoPlanDto> trajectoryPlanRepository;
private readonly TrajectoryPlanExportService trajectoryPlanExportService;
2023-11-28 15:54:47 +05:00
2024-08-19 10:01:07 +05:00
private readonly ITrajectoryEditableRepository<TrajectoryGeoFactDto> trajectoryFactManualReposirory;
private readonly TrajectoryFactManualExportService trajectoryFactManualExportService;
2023-11-28 15:54:47 +05:00
2024-08-19 10:01:07 +05:00
private readonly ITrajectoryNnbRepository trajectoryFactNnbRepository;
private readonly TrajectoryFactNnbExportService trajectoryFactNnbExportService;
2023-11-28 15:54:47 +05:00
2024-08-19 10:01:07 +05:00
private readonly TrajectoryGeoPlanDto[] trajectoryPlanRows = new TrajectoryGeoPlanDto[2] {
new TrajectoryGeoPlanDto() {
Id = 1,
AzimuthGeo = 1,
AzimuthMagnetic = 2,
Comment = "комментарий",
IdUser = 1,
IdWell = 4,
Radius = 3,
UpdateDate = DateTimeOffset.Now,
VerticalDepth = 100,
WellboreDepth = 100,
ZenithAngle = 10
},
new TrajectoryGeoPlanDto() {
Id = 2,
AzimuthGeo = 1,
AzimuthMagnetic = 2,
Comment = "комментарий",
IdUser = 1,
IdWell = 4,
Radius = 3,
UpdateDate = DateTimeOffset.Now,
VerticalDepth = 100,
WellboreDepth = 100,
ZenithAngle = 10
},
};
2023-11-28 15:54:47 +05:00
2024-08-19 10:01:07 +05:00
private readonly TrajectoryGeoFactDto[] trajectoryFactRows = new TrajectoryGeoFactDto[2] {
new TrajectoryGeoFactDto() {
Id = 1,
AzimuthGeo = 1,
AzimuthMagnetic = 2,
Comment = "комментарий",
IdUser = 1,
IdWell = 4,
UpdateDate = DateTimeOffset.Now,
VerticalDepth = 100,
WellboreDepth = 100,
ZenithAngle = 10
},
new TrajectoryGeoFactDto() {
Id = 2,
AzimuthGeo = 1,
AzimuthMagnetic = 2,
Comment = "комментарий",
IdUser = 1,
IdWell = 4,
UpdateDate = DateTimeOffset.Now,
VerticalDepth = 100,
WellboreDepth = 100,
ZenithAngle = 10
},
};
2023-11-28 15:54:47 +05:00
2024-08-19 10:01:07 +05:00
private readonly WellRelatedExportRequest exportOptions = new(idWell);
2024-08-19 10:01:07 +05:00
public TrajectoryExportTest()
{
wellService = Substitute.For<IWellService>();
trajectoryPlanRepository = Substitute.For<ITrajectoryEditableRepository<TrajectoryGeoPlanDto>>();
trajectoryPlanExportService = new TrajectoryPlanExportService(wellService, trajectoryPlanRepository);
2023-11-28 15:54:47 +05:00
2024-08-19 10:01:07 +05:00
trajectoryFactManualReposirory = Substitute.For<ITrajectoryEditableRepository<TrajectoryGeoFactDto>>();
trajectoryFactManualExportService = new TrajectoryFactManualExportService(wellService, trajectoryFactManualReposirory);
2023-11-28 15:54:47 +05:00
2024-08-19 10:01:07 +05:00
trajectoryFactNnbRepository = Substitute.For<ITrajectoryNnbRepository>();
trajectoryFactNnbExportService = new TrajectoryFactNnbExportService(wellService, trajectoryFactNnbRepository);
}
2023-11-28 15:54:47 +05:00
2024-08-19 10:01:07 +05:00
[Fact]
public async Task Export_trajectory_plan()
{
trajectoryPlanRepository.GetAsync(idWell, CancellationToken.None)
.Returns(trajectoryPlanRows);
2024-08-19 10:57:31 +05:00
2024-08-19 10:01:07 +05:00
var stream = await trajectoryPlanExportService.ExportAsync(exportOptions, CancellationToken.None);
Assert.True(stream.File.Length > 0);
}
2023-11-28 15:54:47 +05:00
2024-08-19 10:01:07 +05:00
[Fact]
public async Task Export_trajectory_fact_manual()
{
trajectoryFactManualReposirory.GetAsync(idWell, CancellationToken.None)
.Returns(trajectoryFactRows);
2024-08-19 10:57:31 +05:00
2024-08-19 10:01:07 +05:00
var stream = await trajectoryFactManualExportService.ExportAsync(exportOptions, CancellationToken.None);
Assert.True(stream.File.Length > 0);
}
2023-11-28 15:54:47 +05:00
2024-08-19 10:01:07 +05:00
[Fact]
public async Task Export_trajectory_fact_nnb()
{
trajectoryFactNnbRepository.GetAsync(idWell, CancellationToken.None)
.Returns(trajectoryFactRows);
2024-08-19 10:57:31 +05:00
2024-08-19 10:01:07 +05:00
var stream = await trajectoryFactNnbExportService.ExportAsync(exportOptions, CancellationToken.None);
Assert.True(stream.File.Length > 0);
2023-11-28 15:54:47 +05:00
}
}