DD.WellWorkover.Cloud/AsbCloudWebApi.Tests/Services/Trajectory/TrajectoryParserTest.cs

43 lines
1.4 KiB
C#

using System.Linq;
using AsbCloudApp.Data.Trajectory;
using AsbCloudInfrastructure.Services;
using Xunit;
namespace AsbCloudWebApi.Tests.Services.Trajectory;
public class TrajectoryParserTest
{
private const string UsingTemplateFile = "AsbCloudWebApi.Tests.Services.Trajectory.Templates";
private static readonly ParserServiceFactory parserServiceFactory = new();
[Fact]
public void Parse_trajectory_plan()
{
var stream = System.Reflection.Assembly.GetExecutingAssembly()
.GetManifestResourceStream($"{UsingTemplateFile}.TrajectoryPlanTemplate.xlsx");
if (stream is null)
Assert.Fail("Файла для импорта не существует");
var parserService = parserServiceFactory.GetParser<TrajectoryGeoPlanDto>(ParserServiceFactory.IdTrajectoryPlanParserService);
var trajectoryRows = parserService.Parse(stream);
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("Файла для импорта не существует");
var parserService = parserServiceFactory.GetParser<TrajectoryGeoFactDto>(ParserServiceFactory.IdTrajectoryFactManualParserService);
var trajectoryRows = parserService.Parse(stream);
Assert.Equal(4, trajectoryRows.Item.Count());
}
}