Skip to content

Commit

Permalink
Fixed ReportingEngine test
Browse files Browse the repository at this point in the history
  • Loading branch information
falleretic committed Dec 26, 2023
1 parent 9eaa07e commit c1d4043
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions Examples/ApiExamples/ApiExamples/ExReportingEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1209,17 +1209,18 @@ public void DollarTextFormat()

NumericTestClass testData = new NumericTestBuilder().WithValues(1234, 5621718.589).Build();

ReportingEngine report = new ReportingEngine();
report.KnownTypes.Add(typeof(NumericTestClass));
report.BuildReport(doc, testData, "ds");
ReportingEngine engine = new ReportingEngine();
engine.KnownTypes.Add(typeof(NumericTestClass));
engine.BuildReport(doc, testData, "ds");

doc.Save(ArtifactsDir + "ReportingEngine.DollarTextFormat.docx");
//ExEnd:DollarTextFormat

Assert.AreEqual("one thousand two hundred thirty-four and 00/100\rfive million six hundred twenty-one thousand seven hundred eighteen and 59/100\r\f", doc.GetText());
}

[Test]
[Test, Order(1)]
[Description("Test ordered as first to avoid exception with 'SetRestrictedTypes' after execution other tests.")]
public void RestrictedTypes()
{
//ExStart:RestrictedTypes
Expand All @@ -1230,10 +1231,10 @@ public void RestrictedTypes()
DocumentHelper.CreateSimpleDocument(
"<<var [typeVar = \"\".GetType().BaseType]>><<[typeVar]>>");

// We set "AllowMissingMembers" option to avoid exceptions during building a report.
ReportingEngine engine = new ReportingEngine() { Options = ReportBuildOptions.AllowMissingMembers };
// Note, that you can't set restricted types during or after building a report.
ReportingEngine.SetRestrictedTypes(typeof(System.Type));
// We set "AllowMissingMembers" option to avoid exceptions during building a report.
ReportingEngine engine = new ReportingEngine() { Options = ReportBuildOptions.AllowMissingMembers };
engine.BuildReport(doc, new object());

// We get an empty string because we can't access the GetType() method.
Expand Down

0 comments on commit c1d4043

Please sign in to comment.