forked from ddrilling/AsbCloudServer
129 lines
4.7 KiB
C#
129 lines
4.7 KiB
C#
using AsbCloudApp.Data.Trajectory;
|
|
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;
|
|
using Xunit;
|
|
|
|
namespace AsbCloudInfrastructure.Tests.Services.Trajectory;
|
|
|
|
public class TrajectoryExportTest
|
|
{
|
|
private const int idWell = 4;
|
|
|
|
private IWellService wellService;
|
|
private readonly ITrajectoryEditableRepository<TrajectoryGeoPlanDto> trajectoryPlanRepository;
|
|
private readonly TrajectoryPlanExportService trajectoryPlanExportService;
|
|
|
|
private readonly ITrajectoryEditableRepository<TrajectoryGeoFactDto> trajectoryFactManualReposirory;
|
|
private readonly TrajectoryFactManualExportService trajectoryFactManualExportService;
|
|
|
|
private readonly ITrajectoryNnbRepository trajectoryFactNnbRepository;
|
|
private readonly TrajectoryFactNnbExportService trajectoryFactNnbExportService;
|
|
|
|
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
|
|
},
|
|
};
|
|
|
|
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
|
|
},
|
|
};
|
|
|
|
private readonly WellRelatedExportRequest exportOptions = new(idWell);
|
|
|
|
public TrajectoryExportTest()
|
|
{
|
|
wellService = Substitute.For<IWellService>();
|
|
trajectoryPlanRepository = Substitute.For<ITrajectoryEditableRepository<TrajectoryGeoPlanDto>>();
|
|
trajectoryPlanExportService = new TrajectoryPlanExportService(wellService, trajectoryPlanRepository);
|
|
|
|
trajectoryFactManualReposirory = Substitute.For<ITrajectoryEditableRepository<TrajectoryGeoFactDto>>();
|
|
trajectoryFactManualExportService = new TrajectoryFactManualExportService(wellService, trajectoryFactManualReposirory);
|
|
|
|
trajectoryFactNnbRepository = Substitute.For<ITrajectoryNnbRepository>();
|
|
trajectoryFactNnbExportService = new TrajectoryFactNnbExportService(wellService, trajectoryFactNnbRepository);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Export_trajectory_plan()
|
|
{
|
|
trajectoryPlanRepository.GetAsync(idWell, CancellationToken.None)
|
|
.Returns(trajectoryPlanRows);
|
|
|
|
var stream = await trajectoryPlanExportService.ExportAsync(exportOptions, CancellationToken.None);
|
|
Assert.True(stream.File.Length > 0);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Export_trajectory_fact_manual()
|
|
{
|
|
trajectoryFactManualReposirory.GetAsync(idWell, CancellationToken.None)
|
|
.Returns(trajectoryFactRows);
|
|
|
|
var stream = await trajectoryFactManualExportService.ExportAsync(exportOptions, CancellationToken.None);
|
|
Assert.True(stream.File.Length > 0);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task Export_trajectory_fact_nnb()
|
|
{
|
|
trajectoryFactNnbRepository.GetAsync(idWell, CancellationToken.None)
|
|
.Returns(trajectoryFactRows);
|
|
|
|
var stream = await trajectoryFactNnbExportService.ExportAsync(exportOptions, CancellationToken.None);
|
|
Assert.True(stream.File.Length > 0);
|
|
}
|
|
}
|