简体   繁体   中英

SSRS Unit-Tests: Compare length of 2 Reports

We'd like to create Unit-Test for our Reports (RDLCs), where we set an expected Length on the Test, then Print the report and compare the length of the rendered report with the expected length. For this, we use PDF (since XML etc. is not supported by RDLCs). Interesting enought, it seems like the Size is never exactly the same. We even created a small tolerance of 3 bytes, if we check it, but even then, it fails.

We added a step, where we save the PDF if the Test fails, and funny enought there is a point, where one Report has a Pagebreak and the other doesn't. The Test ran on the same Server, same Settings, same Data. If we compare the Files (via overlapping it), there is just this change.

We tried to pass the DeviceInfo, to assure this doesn't change via:

        const string deviceInfo =
            "<DeviceInfo>" +
            "  <DpiX>600</DpiX>" +
            "  <DpiY>600</DpiY>" +
            "  <HumanReadablePDF>True</HumanReadablePDF>" +
            "  <EmbedFonts>None</EmbedFonts>" +
            "  <StartPage>0</StartPage>" +
            "</DeviceInfo>";

But this doesn't help as well. Has anyone an Idea, why a PDF can be printed differenly, if it uses the same stuff? Or is there anyhow a possibility to create a XML out of the RDLC?

Thanks in advance.

Matthias

You can choose to export to an Excel file instead of PDF and then convert the xls to XML using c#. There is a code sample for this here:

https://code.msdn.microsoft.com/office/How-to-convert-excel-file-7a9bb404

Not the quickest and easiest solution but I think it does the job :)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM