Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kamil-mrzyglod committed Sep 2, 2024
2 parents 2dec9e6 + 88a417d commit 7fdbee8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
22 changes: 22 additions & 0 deletions ace-tests/Reworked/OutputTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,26 @@ public void Output_WhenMarkdownOutputIsRequested_ItShouldGenerateWithoutError()

Assert.That(outputFile, Is.Not.Null);
}

[Test]
public void Output_WhenHtmlOutputIsRequested_ItShouldGenerateWithoutError()
{
var outputFilename = $"ace_test_{DateTime.Now.Ticks}";
var exitCode = Program.Main([
"templates/reworked/automation-account/automation-account.bicep",
"cf70b558-b930-45e4-9048-ebcefb926adf",
"arm-estimator-tests-rg",
"--generateHtmlOutput",
"--htmlOutputFilename",
outputFilename,
"--mocked-retail-api-response-path",
"mocked-responses/retail-api/automation-account/usage-patterns.json"
]);

Assert.That(exitCode, Is.EqualTo(0));

var outputFile = File.ReadAllText($"{outputFilename}.html");

Assert.That(outputFile, Is.Not.Null);
}
}
6 changes: 3 additions & 3 deletions ace/Output/HtmlOutputGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ public void Generate()
foreach (var resource in output.Resources)
{
var id = new ResourceIdentifier(resource.Id);
resultRows += string.Format(tableRow, id.Name, id.ResourceType, $"{resource.TotalCost:F} {output.Currency}", $"{resource.Delta:F} {output.Currency}");
resultRows += string.Format(tableRow, id.Name, id.ResourceType, $"{resource.TotalCost.Value:F} {output.Currency}", $"{resource.Delta.Value:F} {output.Currency}");
}

template = template.Replace("### [ACE-TBODY] ###", resultRows);
template = template.Replace("### [ACE-TFOOT-TOTALSUM] ###", $"{output.TotalCost:F} {output.Currency}");
template = template.Replace("### [ACE-TFOOT-DELTASUM] ###", $"{output.Delta:F} {output.Currency}");
template = template.Replace("### [ACE-TFOOT-TOTALSUM] ###", $"{output.TotalCost.Value:F} {output.Currency}");
template = template.Replace("### [ACE-TFOOT-DELTASUM] ###", $"{output.Delta.Value:F} {output.Currency}");
template = template.Replace("### [ACE-FOOTER-REPORTDATE] ###", DateTime.Now.ToString());
template = template.Replace("### [ACE-BASIC-TD-ALLRESOURCES] ###", output.TotalResourceCount.ToString());
template = template.Replace("### [ACE-BASIC-TD-ESTIMATEDRESOURCES] ###", output.EstimatedResourceCount.ToString());
Expand Down

0 comments on commit 7fdbee8

Please sign in to comment.