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;
|
|
|
|
|
|
2023-11-30 10:27:38 +05:00
|
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|