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

49 lines
1.7 KiB
C#
Raw Normal View History

2023-11-30 09:40:51 +05:00
using AsbCloudInfrastructure.Services.Trajectory.Import;
2023-11-28 15:54:47 +05:00
using System.Linq;
using Xunit;
namespace AsbCloudWebApi.Tests.UnitTests.Services.Trajectory
2023-11-28 15:54:47 +05:00
{
public class TrajectoryImportTest
{
2023-11-30 15:08:58 +05:00
private readonly TrajectoryPlanParserService trajectoryPlanImportService;
2023-11-30 09:40:51 +05:00
private readonly TrajectoryFactManualParserService trajectoryFactManualImportService;
2023-11-28 15:54:47 +05:00
private string usingTemplateFile = "AsbCloudWebApi.Tests.Services.Trajectory.Templates";
public TrajectoryImportTest()
{
2023-11-30 15:08:58 +05:00
trajectoryPlanImportService = new TrajectoryPlanParserService();
2023-11-30 09:40:51 +05:00
trajectoryFactManualImportService = new TrajectoryFactManualParserService();
2023-11-28 15:54:47 +05:00
}
[Fact]
2023-11-30 09:40:51 +05:00
public void Import_trajectory_planned()
2023-11-28 15:54:47 +05:00
{
var stream = System.Reflection.Assembly.GetExecutingAssembly()
2023-11-30 15:08:58 +05:00
.GetManifestResourceStream($"{usingTemplateFile}.TrajectoryPlanTemplate.xlsx");
2023-11-28 15:54:47 +05:00
if (stream is null)
Assert.Fail("Файла для импорта не существует");
2023-11-30 15:08:58 +05:00
var trajectoryRows = trajectoryPlanImportService.Import(stream);
2023-11-30 09:40:51 +05:00
2023-11-28 15:54:47 +05:00
Assert.Equal(3, trajectoryRows.Count());
}
[Fact]
2023-11-30 09:40:51 +05:00
public void Import_trajectory_fact_manual()
2023-11-28 15:54:47 +05:00
{
var stream = System.Reflection.Assembly.GetExecutingAssembly()
.GetManifestResourceStream($"{usingTemplateFile}.TrajectoryFactManualTemplate.xlsx");
if (stream is null)
Assert.Fail("Файла для импорта не существует");
2023-11-30 15:08:58 +05:00
var trajectoryRows = trajectoryFactManualImportService.Import(stream);
2023-11-30 09:40:51 +05:00
2023-11-28 15:54:47 +05:00
Assert.Equal(4, trajectoryRows.Count());
}
}
}