4.4.  Comparing Attachments

Quantity

Compare the number of attachments in two documents:

<testcase name="haveSameNumberOfEmbeddedFiles">
  <assertThat testDocument="test/test.pdf"
              masterDocument="master/master.pdf"
  >
    <haveSameNumberOfEmbeddedFiles />
  </assertThat>
</testcase>

Name and Content

To compare the attachments by name or by content you can use the tag <haveSameEmbeddedFiles />:

<testcase name="haveSameEmbeddedFiles">
  <assertThat testDocument="test/test.pdf"
              masterDocument="master/master.pdf"
  >
    <haveSameEmbeddedFiles comparedBy="NAME" />
    <haveSameEmbeddedFiles comparedBy="CONTENT" /> 1
  </assertThat>
</testcase>

1

The attachments are compared byte-by-byte. So two files of any type can be compared.

The attribute comparedBy=".." provides the two constants NAME and CONTENT.

You can use the utility ExtractEmbeddedFiles to extract the attachments. See chapter 9.4: “Extract Attachments”.