DD.WellWorkover.Cloud/AsbCloudWebApi.Tests/UnitTests/Services/Trajectory/TrajectoryExportTest.cs

128 lines
4.9 KiB
C#
Raw Normal View History

2023-11-28 15:54:47 +05:00
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 Xunit;
namespace AsbCloudWebApi.Tests.UnitTests.Services.Trajectory
2023-11-28 15:54:47 +05:00
{
public class TrajectoryExportTest
{
private IWellService wellService;
2023-11-30 15:08:58 +05:00
private readonly ITrajectoryEditableRepository<TrajectoryGeoPlanDto> trajectoryPlanRepository;
private readonly TrajectoryPlanExportService trajectoryPlanExportService;
2023-11-28 15:54:47 +05:00
private readonly ITrajectoryEditableRepository<TrajectoryGeoFactDto> trajectoryFactManualReposirory;
private readonly TrajectoryFactManualExportService trajectoryFactManualExportService;
private readonly ITrajectoryNnbRepository trajectoryFactNnbRepository;
private readonly TrajectoryFactNnbExportService trajectoryFactNnbExportService;
2023-11-30 09:40:51 +05:00
private readonly int idWell = 4;
2023-11-30 15:08:58 +05:00
private readonly TrajectoryGeoPlanDto[] trajectoryPlanRows = new TrajectoryGeoPlanDto[2] {
2023-11-28 15:54:47 +05:00
new TrajectoryGeoPlanDto() {
Id = 1,
AzimuthGeo = 1,
AzimuthMagnetic = 2,
Comment = "комментарий",
IdUser = 1,
IdWell = 4,
Radius = 3,
UpdateDate = DateTime.Now,
VerticalDepth = 100,
WellboreDepth = 100,
ZenithAngle = 10
},
new TrajectoryGeoPlanDto() {
Id = 2,
AzimuthGeo = 1,
AzimuthMagnetic = 2,
Comment = "комментарий",
IdUser = 1,
IdWell = 4,
Radius = 3,
UpdateDate = DateTime.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 = DateTime.Now,
VerticalDepth = 100,
WellboreDepth = 100,
ZenithAngle = 10
},
new TrajectoryGeoFactDto() {
Id = 2,
AzimuthGeo = 1,
AzimuthMagnetic = 2,
Comment = "комментарий",
IdUser = 1,
IdWell = 4,
UpdateDate = DateTime.Now,
VerticalDepth = 100,
WellboreDepth = 100,
ZenithAngle = 10
},
};
public TrajectoryExportTest()
{
wellService = Substitute.For<IWellService>();
2023-11-30 15:08:58 +05:00
trajectoryPlanRepository = Substitute.For<ITrajectoryEditableRepository<TrajectoryGeoPlanDto>>();
trajectoryPlanExportService = new TrajectoryPlanExportService(wellService, trajectoryPlanRepository);
2023-11-28 15:54:47 +05:00
trajectoryFactManualReposirory = Substitute.For<ITrajectoryEditableRepository<TrajectoryGeoFactDto>>();
trajectoryFactManualExportService = new TrajectoryFactManualExportService(wellService, trajectoryFactManualReposirory);
trajectoryFactNnbRepository = Substitute.For<ITrajectoryNnbRepository>();
trajectoryFactNnbExportService = new TrajectoryFactNnbExportService(wellService, trajectoryFactNnbRepository);
}
[Fact]
2023-11-30 15:20:22 +05:00
public async Task Export_trajectory_plan()
2023-11-28 15:54:47 +05:00
{
2023-11-30 15:08:58 +05:00
trajectoryPlanRepository.GetAsync(idWell, CancellationToken.None)
.Returns(trajectoryPlanRows);
2023-11-28 15:54:47 +05:00
2023-11-30 15:08:58 +05:00
var stream = await trajectoryPlanExportService.ExportAsync(idWell, CancellationToken.None);
2023-11-28 15:54:47 +05:00
Assert.True(stream.Length > 0);
}
[Fact]
public async Task Export_trajectory_fact_manual()
{
2023-11-30 09:40:51 +05:00
trajectoryFactManualReposirory.GetAsync(idWell, CancellationToken.None)
2023-11-28 15:54:47 +05:00
.Returns(trajectoryFactRows);
2023-11-30 09:40:51 +05:00
var stream = await trajectoryFactManualExportService.ExportAsync(idWell, CancellationToken.None);
2023-11-28 15:54:47 +05:00
Assert.True(stream.Length > 0);
}
[Fact]
public async Task Export_trajectory_fact_nnb()
{
2023-11-30 09:40:51 +05:00
trajectoryFactNnbRepository.GetAsync(idWell, CancellationToken.None)
2023-11-28 15:54:47 +05:00
.Returns(trajectoryFactRows);
2023-11-30 09:40:51 +05:00
var stream = await trajectoryFactNnbExportService.ExportAsync(idWell, CancellationToken.None);
2023-11-28 15:54:47 +05:00
Assert.True(stream.Length > 0);
}
}
}