Created
September 7, 2020 07:27
-
-
Save serpel/a88c0acb00aaa4d49115fadb0ac0197c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Collection("api")] | |
public class DryingReportTests | |
{ | |
private static readonly string OutputPath = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory) + @"\~DRTestOutput\"; | |
private readonly TestContext _context; | |
public DryingReportTests(TestContext context) | |
=> _context = context; | |
[Fact(Skip = "Do not run in pipeline - test used for verification and actual PDF generation")] | |
public async System.Threading.Tasks.Task GeneratesValidReport() | |
{ | |
var jobId = Guid.NewGuid(); | |
var response = await _context.Client.PostAsync($"api/jobs/{jobId}/drybook/command/generate-drying-report?isMock={DryingReportTestScenarios.MockData}",null); | |
response.HandleInvalidResponse(); | |
var result = response.Content.ReadAsByteArrayAsync(); | |
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | |
{ | |
var filePath = OutputPath + @"\DryingReportTests.ValidReport.pdf"; | |
if (StringExtensions.FileOrDirectoryExists(OutputPath) || StringExtensions.FileOrDirectoryExists(filePath)) | |
File.WriteAllBytes(filePath, result.Result); | |
} | |
} | |
[Trait("Category", "LongRunning")] | |
[Fact] | |
public async System.Threading.Tasks.Task FullyPopulatedJob_GeneratesValidReport() | |
{ | |
#region ARRANGE | |
var dryingReportJobBuilder = new DryingReportJobBuilder(_context); | |
var jobId = await dryingReportJobBuilder.Build(); | |
#endregion | |
#region ACT | |
var dryingReportCommand = new GenerateDryingReport.Command(jobId); | |
var services = _context.Services; | |
ILogger<GenerateDryingReport> logger = services.GetService(typeof(ILogger<GenerateDryingReport>)) as ILogger<GenerateDryingReport>; | |
var dryingReportHandler = new GenerateDryingReport.Handler(_context.Mediator, logger, _context.DbContext); | |
var dryingReportResult = await dryingReportHandler.Handle(dryingReportCommand, CancellationToken.None); | |
#endregion | |
#region ASSERT | |
dryingReportResult.Should().NotBeNull(); | |
dryingReportResult.EquipmentUsageModel.ZoneEquipmentUsages.Count.Should().Be(2); | |
dryingReportResult.DailyEquipmentCountModel.EquipmentPlacementCountByDay?.Count.Should().Be(2); | |
dryingReportResult.DailyEquipmentCountModel.EquipmentSummary.Count.Should().Be(2); | |
//TODO: complete when DailyNarratives are able to be validated (waiting on future sprint) | |
//dryingReportResult.DailyNarrativeModel.DailyNarratives.Count.Should().Be(0); | |
dryingReportResult.MonitoringModel.AtmosphericReadingsModel.ZoneReadingSets.Count.Should().Be(2); | |
dryingReportResult.MonitoringModel.MoistureContentReadingsModel.MoistureContentReadings.Count.Should().Be(2); | |
dryingReportResult.ZoneCompositionModel.ZoneCompositions.Count.Should().Be(2); | |
#endregion | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment