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