using AsbCloudInfrastructure.Services.Trajectory.Import; using System.Linq; using Xunit; namespace AsbCloudWebApi.Tests.UnitTests.Services.Trajectory { public class TrajectoryImportTest { private readonly TrajectoryPlannedParserService trajectoryPlannedImportService; private readonly TrajectoryFactManualParserService trajectoryFactManualImportService; private string usingTemplateFile = "AsbCloudWebApi.Tests.Services.Trajectory.Templates"; public TrajectoryImportTest() { trajectoryPlannedImportService = new TrajectoryPlannedParserService(); trajectoryFactManualImportService = new TrajectoryFactManualParserService(); } [Fact] public void Import_trajectory_planned() { var stream = System.Reflection.Assembly.GetExecutingAssembly() .GetManifestResourceStream($"{usingTemplateFile}.TrajectoryPlannedTemplate.xlsx"); if (stream is null) Assert.Fail("Файла для импорта не существует"); var trajectoryRows = trajectoryPlannedImportService.ImportAsync(stream); Assert.Equal(3, trajectoryRows.Count()); } [Fact] public void Import_trajectory_fact_manual() { var stream = System.Reflection.Assembly.GetExecutingAssembly() .GetManifestResourceStream($"{usingTemplateFile}.TrajectoryFactManualTemplate.xlsx"); if (stream is null) Assert.Fail("Файла для импорта не существует"); var trajectoryRows = trajectoryFactManualImportService.ImportAsync(stream); Assert.Equal(4, trajectoryRows.Count()); } } }