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

129 lines
5.0 KiB
C#

using AsbCloudApp.Data.Trajectory;
using AsbCloudApp.Repositories;
using AsbCloudApp.Requests;
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
{
public class TrajectoryExportTest
{
private IWellService wellService;
private readonly ITrajectoryEditableRepository<TrajectoryGeoPlanDto> trajectoryPlannedRepository;
private readonly TrajectoryPlannedExportService trajectoryPlannedExportService;
private readonly ITrajectoryEditableRepository<TrajectoryGeoFactDto> trajectoryFactManualReposirory;
private readonly TrajectoryFactManualExportService trajectoryFactManualExportService;
private readonly ITrajectoryNnbRepository trajectoryFactNnbRepository;
private readonly TrajectoryFactNnbExportService trajectoryFactNnbExportService;
private readonly int idWell = 4;
private readonly TrajectoryGeoPlanDto[] trajectoryPlannedRows = new TrajectoryGeoPlanDto[2] {
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>();
trajectoryPlannedRepository = Substitute.For<ITrajectoryEditableRepository<TrajectoryGeoPlanDto>>();
trajectoryPlannedExportService = new TrajectoryPlannedExportService(wellService, trajectoryPlannedRepository);
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_planned()
{
trajectoryPlannedRepository.GetAsync(idWell, CancellationToken.None)
.Returns(trajectoryPlannedRows);
var stream = await trajectoryPlannedExportService.ExportAsync(idWell, CancellationToken.None);
Assert.True(stream.Length > 0);
}
[Fact]
public async Task Export_trajectory_fact_manual()
{
trajectoryFactManualReposirory.GetAsync(idWell, CancellationToken.None)
.Returns(trajectoryFactRows);
var stream = await trajectoryFactManualExportService.ExportAsync(idWell, CancellationToken.None);
Assert.True(stream.Length > 0);
}
[Fact]
public async Task Export_trajectory_fact_nnb()
{
trajectoryFactNnbRepository.GetAsync(idWell, CancellationToken.None)
.Returns(trajectoryFactRows);
var stream = await trajectoryFactNnbExportService.ExportAsync(idWell, CancellationToken.None);
Assert.True(stream.Length > 0);
}
}
}