public void GenerateXHTMLForEntry_PrimaryEntryReferencesWork_ComplexFormOfSense()
        {
            var mainRevEntryNode = PreparePrimaryEntryReferencesConfigSetup();
            var reversalEntry    = CreateInterestingEnglishReversalEntry("spokesmanRevForm", "porte-parole", "spokesman:gloss");
            var referringSense   = reversalEntry.ReferringSenses.First();
            var paroleEntry      = CXGTests.CreateInterestingLexEntry(Cache, "parole", "speech");

            CXGTests.CreateComplexForm(Cache, paroleEntry.SensesOS[0], referringSense.Owner as ILexEntry, true);
            //SUT
            var          result       = ConfiguredXHTMLGenerator.GenerateXHTMLForEntry(reversalEntry, mainRevEntryNode, null, DefaultSettings);
            const string refTypeXpath = entryRefTypeXpath + "/span[@class='abbreviation']/span[@lang='en' and text()='comp. of']";

            AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(refTypeXpath, 1);
            AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(refHeadwordXpath, 1);
            const string glossOrSummDefXpath = primaryEntryXpath + "/span[@class='glossorsummary']/span[@lang='en' and text()='speech']";

            AssertThatXmlIn.String(result).HasSpecifiedNumberOfMatchesForXpath(glossOrSummDefXpath, 1);
        }
        public void GenerateXHTMLForEntry_PrimaryEntryReferences_Ordered()
        {
            var mainRevEntryNode = PreparePrimaryEntryReferencesConfigSetup();

            var reversalEntry = CreateInterestingEnglishReversalEntry();
            var primaryEntry  = reversalEntry.ReferringSenses.First().Entry;
            var refer1        = CXGTests.CreateInterestingLexEntry(Cache, "Component Entry", "CompEntry Sense");
            var refer2        = CXGTests.CreateInterestingLexEntry(Cache, "Variant Entry");
            var refer3        = CXGTests.CreateInterestingLexEntry(Cache, "CompSense Entry", "Component Sense").SensesOS.First();
            var refer4        = CXGTests.CreateInterestingLexEntry(Cache, "Invariant Entry");
            var refer5        = CXGTests.CreateInterestingLexEntry(Cache, "Variante Entrie");

            using (CXGTests.CreateComplexForm(Cache, refer3, primaryEntry, new Guid("00000000-0000-0000-cccc-000000000000"), true))             // Compound
                using (CXGTests.CreateVariantForm(Cache, refer2, primaryEntry, new Guid("00000000-0000-0000-bbbb-000000000000"), "Free Variant"))
                    using (CXGTests.CreateComplexForm(Cache, refer1, primaryEntry, new Guid("00000000-0000-0000-aaaa-000000000000"), true))     // Compound
                        using (CXGTests.CreateVariantForm(Cache, refer4, primaryEntry, new Guid("00000000-0000-0000-dddd-000000000000"), null)) // no Variant Type
                            using (CXGTests.CreateVariantForm(Cache, refer5, primaryEntry, new Guid("00000000-0000-0000-eeee-000000000000"), "Spelling Variant"))
                            {
                                var result   = ConfiguredXHTMLGenerator.GenerateXHTMLForEntry(reversalEntry, mainRevEntryNode, null, DefaultSettings); // SUT
                                var assertIt = AssertThatXmlIn.String(result);
                                assertIt.HasSpecifiedNumberOfMatchesForXpath(entryRefTypeXpath, 3);                                                    // should be one Complex Form Type and two Variant Types.
                                const string headwordBit = "/span[@class='headword']/span[@lang='fr']/a[text()='{1}']";
                                const string entryRefWithSiblingXpath = entryRefsXpath + "/span[@class='mainentryref' and preceding-sibling::";
                                const string typeAndHeadwordXpath     = entryRefWithSiblingXpath
                                                                        + entryRefTypeBit + "/span[@class='abbreviation']/span[@lang='en' and text()='{0}']]" + primaryLexemeBit + headwordBit;
                                var adjacentHeadwordXpath = entryRefWithSiblingXpath
                                                            + "span[@class='mainentryref']" + primaryLexemeBit + headwordBit.Replace("{1}", "{0}") + "]" + primaryLexemeBit + headwordBit;
                                // check for proper headings on each referenced headword
                                assertIt.HasSpecifiedNumberOfMatchesForXpath(string.Format(typeAndHeadwordXpath, "comp. of", "Component Entry"), 1);
                                assertIt.HasSpecifiedNumberOfMatchesForXpath(string.Format(adjacentHeadwordXpath, "Component Entry", "CompSense Entry"), 1); // ordered within heading
                                assertIt.HasSpecifiedNumberOfMatchesForXpath(string.Format(typeAndHeadwordXpath, "fr. var. of", "Variant Entry"), 1);
                                assertIt.HasSpecifiedNumberOfMatchesForXpath(string.Format(typeAndHeadwordXpath, "sp. var. of", "Variante Entrie"), 1);
                                // verify there is no heading on the typeless variant
                                assertIt.HasNoMatchForXpath(string.Format(entryRefWithSiblingXpath + "span]" + primaryLexemeBit + headwordBit, null, "Invariant Entry"),
                                                            message: "Invariant Entry is the only typeless entry ref; it should not have any preceding siblings (Types or other Entry Refs)");
                            }
        }