2024-02-14 14:13:43 +05:00
|
|
|
|
using System.Linq;
|
2024-01-29 15:03:53 +05:00
|
|
|
|
using AsbCloudApp.Data.Trajectory;
|
2024-02-01 16:35:29 +05:00
|
|
|
|
using AsbCloudApp.Requests.ParserOptions;
|
2024-02-13 16:05:16 +05:00
|
|
|
|
using AsbCloudInfrastructure.Services.Parser;
|
2024-01-29 15:03:53 +05:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace AsbCloudWebApi.Tests.Services.Trajectory;
|
|
|
|
|
|
|
|
|
|
public class TrajectoryParserTest
|
|
|
|
|
{
|
|
|
|
|
private const string UsingTemplateFile = "AsbCloudWebApi.Tests.Services.Trajectory.Templates";
|
|
|
|
|
|
2024-02-01 16:35:29 +05:00
|
|
|
|
private readonly ParserServiceFactory parserServiceFactory;
|
|
|
|
|
|
2024-01-29 15:03:53 +05:00
|
|
|
|
[Fact]
|
|
|
|
|
public void Parse_trajectory_plan()
|
|
|
|
|
{
|
|
|
|
|
var stream = System.Reflection.Assembly.GetExecutingAssembly()
|
|
|
|
|
.GetManifestResourceStream($"{UsingTemplateFile}.TrajectoryPlanTemplate.xlsx");
|
|
|
|
|
|
|
|
|
|
if (stream is null)
|
|
|
|
|
Assert.Fail("Файла для импорта не существует");
|
|
|
|
|
|
2024-02-01 16:35:29 +05:00
|
|
|
|
var parserService = parserServiceFactory.Create<TrajectoryGeoPlanDto, IParserOptionsRequest>(
|
2024-02-14 14:13:43 +05:00
|
|
|
|
ParserIds.IdTrajectoryPlanParser);
|
2024-02-01 16:35:29 +05:00
|
|
|
|
|
|
|
|
|
var trajectoryRows = parserService.Parse(stream, IParserOptionsRequest.Empty());
|
2024-01-29 15:03:53 +05:00
|
|
|
|
|
|
|
|
|
Assert.Equal(3, trajectoryRows.Item.Count());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void Parse_trajectory_fact_manual()
|
|
|
|
|
{
|
|
|
|
|
var stream = System.Reflection.Assembly.GetExecutingAssembly()
|
|
|
|
|
.GetManifestResourceStream($"{UsingTemplateFile}.TrajectoryFactManualTemplate.xlsx");
|
|
|
|
|
|
|
|
|
|
if (stream is null)
|
|
|
|
|
Assert.Fail("Файла для импорта не существует");
|
|
|
|
|
|
2024-02-01 16:35:29 +05:00
|
|
|
|
var parserService = parserServiceFactory.Create<TrajectoryGeoFactDto, IParserOptionsRequest>(
|
2024-02-14 14:13:43 +05:00
|
|
|
|
ParserIds.IdTrajectoryFactManualParser);
|
2024-02-01 16:35:29 +05:00
|
|
|
|
|
|
|
|
|
var trajectoryRows = parserService.Parse(stream, IParserOptionsRequest.Empty());
|
2024-01-29 15:03:53 +05:00
|
|
|
|
|
|
|
|
|
Assert.Equal(4, trajectoryRows.Item.Count());
|
|
|
|
|
}
|
|
|
|
|
}
|