0

In my WPF application I'm generating an xps report based on a flowdocument.

I've tested all the ViewModel part of the generation with unit tests, but I'd like to add an acceptance test (using specflow, http://www.specflow.org/) that compares the newly created report against an nominal report in order to avoid unwanted changes in the future.

Unfortunately, the unzipped content of the generated xps differs in GUID's of the embedded resources (e.g the font) each time the report is re-generated. I guess comparing the fixed pages in /Documents/1/Pages is enough, but nevertheless the fonts are referenced with GUID in there.

compare two xps documents

fixed page differences

Is there a way how I can compare xps files ignoring GUID part? Can someone give me a hint to the right Direction?

it's me
  • 133
  • 1
  • 1
  • 7
  • If it's only the GUID that changes, then i would use a RegEx to remove all GUIDs from both files, and then compare them (with the GUIDs removed they should be identical). Take a look at this ... http://stackoverflow.com/questions/11040707/c-sharp-regex-for-guid – 3-14159265358979323846264 Jul 14 '15 at 10:38
  • Thank you, Mr. π. I found out that there are a few more dynamic parts in the resulting xps and ended up with the following regex to remove these before comparing: `new Regex(@"(ImageSource|FontUri)\s*=\s*(""[^""]*\"")", RegexOptions.Compiled);` – it's me Jul 15 '15 at 07:50
  • Nice work :0) And that's the first time I've been called Mr π, so thanks! lol :0) – 3-14159265358979323846264 Jul 15 '15 at 07:52

0 Answers0