mercredi 4 mai 2016

How to implement a Xspec unit testing?

Does anyone know how to test this simple code using the XSpec in XSLT?

<xsl:template match="@NameTitle">       
    <NameTitle Value="{if(. = ('Sir', 'Lady', 'Hon', 'R Hon')) then 'Other' else .}"
         Description="{if(. = ('Sir', 'Lady', 'Hon', 'R Hon')) then . else ''}"/>
</xsl:template>


<xsl:template match="BusinessChannel/Contact/ContactPerson | SalesChannel/LoanWriter">
    <PersonName>
        <xsl:apply-templates select="@NameTitle"/>
        <FirstName>
            <xsl:value-of select="@FirstName"/>
        </FirstName>
        <Surname>
            <xsl:value-of select="@Surname"/>
        </Surname>
    </PersonName>
</xsl:template>

Using Xspec is simple for testing functions from a beginner point of view but for templates that select attributes is not(At least for me at the moment, because now I have started to use it).

Ex: This was easy:

    <xsl:function name="fn:RemoveSpace">
        <xsl:param name="RemoveSpace"/>
        <xsl:if test="$RemoveSpace != ''">
            <xsl:value-of select="translate($RemoveSpace, ' ', '')"/>   
        </xsl:if>
    </xsl:function>

    <x:scenario label="Scenario for testing function RemoveSpace">
       <x:call function="fn:RemoveSpace">
           <x:param name="RemoveSpace" select="'Person Applicant'"/>
       </x:call>
       <x:expect label="Remove the white space">PersonApplicant</x:expect>
    </x:scenario>

Any suggestion is welcome. P.S. I'm using Xspec from OxygenXML.

Aucun commentaire:

Enregistrer un commentaire