示例#1
0
        public void CanDeepCloneWritingSystemOptions()
        {
            var orig = new DictionaryNodeWritingSystemOptions
            {
                WsType  = DictionaryNodeWritingSystemOptions.WritingSystemType.Vernacular,
                Options = new List <DictionaryNodeListOptions.DictionaryNodeOption>
                {
                    new DictionaryNodeListOptions.DictionaryNodeOption {
                        Id = "ws1", IsEnabled = true
                    },
                    new DictionaryNodeListOptions.DictionaryNodeOption {
                        Id = "ws2", IsEnabled = false
                    },
                    new DictionaryNodeListOptions.DictionaryNodeOption {
                        Id = "ws3", IsEnabled = true
                    },
                },
                DisplayWritingSystemAbbreviations = true
            };

            // SUT
            var genericClone = orig.DeepClone();

            var clone = genericClone as DictionaryNodeWritingSystemOptions;

            Assert.NotNull(clone, "Incorrect subclass returned; expected DictionaryNodeWritingSystemOptions");
            Assert.AreNotSame(orig, clone, "Not deep cloned; shallow cloned");
            Assert.AreEqual(orig.WsType, clone.WsType);
            Assert.AreEqual(orig.DisplayWritingSystemAbbreviations, clone.DisplayWritingSystemAbbreviations);
            AssertListWasDeepCloned(orig.Options, clone.Options);
        }
        private static void CreateSubsenseModel()
        {
            var wsOpts = new DictionaryNodeWritingSystemOptions
            {
                Options = new List <DictionaryNodeListOptions.DictionaryNodeOption>
                {
                    new DictionaryNodeListOptions.DictionaryNodeOption {
                        Id = "en"
                    }
                }
            };
            var DictionaryNodeSenseOptions = new DictionaryNodeSenseOptions
            {
                BeforeNumber   = "",
                AfterNumber    = ")",
                NumberStyle    = "Dictionary-SenseNumber",
                NumberingStyle = "%d",
                DisplayEachSenseInAParagraph = false,
                NumberEvenASingleSense       = true,
                ShowSharedGrammarInfoFirst   = false
            };
            var DictionaryNodeSubSenseOptions = new DictionaryNodeSenseOptions
            {
                BeforeNumber   = "",
                AfterNumber    = ")",
                NumberStyle    = "Dictionary-SenseNumber",
                NumberingStyle = "%O",
                DisplayEachSenseInAParagraph = false,
                NumberEvenASingleSense       = true,
                ShowSharedGrammarInfoFirst   = false
            };

            var glossNode = new ConfigurableDictionaryNode {
                FieldDescription = "Gloss", DictionaryNodeOptions = wsOpts
            };
            var subSenseNode = new ConfigurableDictionaryNode
            {
                FieldDescription     = "SensesOS",
                CSSClassNameOverride = "senses",
                Label = "Subsenses",
                DictionaryNodeOptions = DictionaryNodeSubSenseOptions,
                Children = new List <ConfigurableDictionaryNode> {
                    glossNode
                }
            };
            var sensesNode = new ConfigurableDictionaryNode
            {
                FieldDescription      = "SensesOS",
                CSSClassNameOverride  = "senses",
                DictionaryNodeOptions = DictionaryNodeSenseOptions,
                Children = new List <ConfigurableDictionaryNode> {
                    glossNode, subSenseNode
                }
            };

            var mainEntryNode = new ConfigurableDictionaryNode
            {
                FieldDescription = "LexEntry",
                Children         = new List <ConfigurableDictionaryNode> {
                    sensesNode
                }
            };

            CssGeneratorTests.PopulateFieldsForTesting(mainEntryNode);
        }
        public void GenerateXHTMLForEntry_VernacularFormWithSubSensesinReversalSubEntry()
        {
            var headwordNode = new ConfigurableDictionaryNode
            {
                FieldDescription      = "ReversalName",
                Label                 = "Headword",
                CSSClassNameOverride  = "headword",
                DictionaryNodeOptions = new DictionaryNodeWritingSystemOptions
                {
                    WsType  = DictionaryNodeWritingSystemOptions.WritingSystemType.Vernacular,
                    Options = new List <DictionaryNodeListOptions.DictionaryNodeOption>
                    {
                        new DictionaryNodeListOptions.DictionaryNodeOption {
                            Id = "vernacular"
                        }
                    }
                }
            };
            var wsOpts = new DictionaryNodeWritingSystemOptions
            {
                WsType  = DictionaryNodeWritingSystemOptions.WritingSystemType.Reversal,
                Options = new List <DictionaryNodeListOptions.DictionaryNodeOption>
                {
                    new DictionaryNodeListOptions.DictionaryNodeOption {
                        Id = "reversal"
                    }
                }
            };
            var glossNode = new ConfigurableDictionaryNode {
                FieldDescription = "Gloss", DictionaryNodeOptions = wsOpts
            };
            var formNode = new ConfigurableDictionaryNode
            {
                FieldDescription      = "ReferringSenses",
                DictionaryNodeOptions = new DictionaryNodeSenseOptions {
                    NumberingStyle = "%d", NumberEvenASingleSense = true
                },
                Children = new List <ConfigurableDictionaryNode> {
                    headwordNode, glossNode
                }
            };
            var subEntryNode = new ConfigurableDictionaryNode
            {
                FieldDescription      = "SubentriesOS",
                CSSClassNameOverride  = "subentries",
                DictionaryNodeOptions = new DictionaryNodeListAndParaOptions {
                    DisplayEachInAParagraph = true
                },
                Children = new List <ConfigurableDictionaryNode> {
                    formNode
                }
            };
            var mainEntryNode = new ConfigurableDictionaryNode
            {
                DictionaryNodeOptions = new DictionaryNodeWritingSystemOptions
                {
                    WsType  = DictionaryNodeWritingSystemOptions.WritingSystemType.Reversal,
                    Options = new List <DictionaryNodeListOptions.DictionaryNodeOption>
                    {
                        new DictionaryNodeListOptions.DictionaryNodeOption {
                            Id = "en"
                        }
                    },
                    DisplayWritingSystemAbbreviations = false
                },
                FieldDescription = "ReversalIndexEntry",
                Children         = new List <ConfigurableDictionaryNode> {
                    subEntryNode
                }
            };

            CssGeneratorTests.PopulateFieldsForTesting(mainEntryNode);
            var testEntry = CreateInterestingEnglishSubReversalEntryWithSubSense();
            //SUT
            var          xhtml          = ConfiguredXHTMLGenerator.GenerateXHTMLForEntry(testEntry, mainEntryNode, null, DefaultSettings);
            const string subSenseOneOne = "/div[@class='reversalindexentry']/span[@class='subentries']/span[@class='subentry']/span[@class='referringsenses']/span[@class='sensecontent']/span[@class='referringsense']/span[@class='headword']/span/span/a[text()='1.1']";

            AssertThatXmlIn.String(xhtml).HasSpecifiedNumberOfMatchesForXpath(subSenseOneOne, 1);
        }
        public void GenerateXHTMLForEntry_VernacularFormWithSubSenses()
        {
            var headwordNode = new ConfigurableDictionaryNode
            {
                FieldDescription      = "ReversalName",
                CSSClassNameOverride  = "headword",
                DictionaryNodeOptions = new DictionaryNodeWritingSystemOptions
                {
                    WsType  = DictionaryNodeWritingSystemOptions.WritingSystemType.Vernacular,
                    Options = new List <DictionaryNodeListOptions.DictionaryNodeOption>
                    {
                        new DictionaryNodeListOptions.DictionaryNodeOption {
                            Id = "vernacular"
                        }
                    }
                }
            };
            var wsOpts = new DictionaryNodeWritingSystemOptions
            {
                WsType  = DictionaryNodeWritingSystemOptions.WritingSystemType.Reversal,
                Options = new List <DictionaryNodeListOptions.DictionaryNodeOption>
                {
                    new DictionaryNodeListOptions.DictionaryNodeOption {
                        Id = "reversal"
                    }
                }
            };
            var glossNode = new ConfigurableDictionaryNode {
                FieldDescription = "Gloss", DictionaryNodeOptions = wsOpts
            };
            var formNode = new ConfigurableDictionaryNode
            {
                FieldDescription      = "ReferringSenses",
                DictionaryNodeOptions = new DictionaryNodeSenseOptions {
                    NumberingStyle = "%d"
                },
                Children = new List <ConfigurableDictionaryNode> {
                    headwordNode, glossNode
                }
            };
            var mainEntryNode = new ConfigurableDictionaryNode
            {
                DictionaryNodeOptions = new DictionaryNodeWritingSystemOptions
                {
                    WsType  = DictionaryNodeWritingSystemOptions.WritingSystemType.Reversal,
                    Options = new List <DictionaryNodeListOptions.DictionaryNodeOption>
                    {
                        new DictionaryNodeListOptions.DictionaryNodeOption {
                            Id = "en"
                        }
                    },
                    DisplayWritingSystemAbbreviations = false
                },
                FieldDescription = "ReversalIndexEntry",
                Children         = new List <ConfigurableDictionaryNode> {
                    formNode
                }
            };

            CssGeneratorTests.PopulateFieldsForTesting(mainEntryNode);
            var testEntry = CreateInterestingEnglishReversalEntry();

            AddSingleSubSenseToSense(testEntry, "second gloss", m_wsEn, Cache);
            //SUT
            var xhtml = ConfiguredXHTMLGenerator.GenerateXHTMLForEntry(testEntry, mainEntryNode, null, DefaultSettings);
            // REVIEW (Hasso) 2016.03: we should probably do something about the leading space in the Sense Number Run, as it is currently in addition to the "between" space.
            const string subSenseOneOne = "/div[@class='reversalindexentry']/span[@class='referringsenses']/span[@class='sensecontent']/span[@class='referringsense']/span[@class='headword']/span/span/a[text()='1.1']";

            AssertThatXmlIn.String(xhtml).HasSpecifiedNumberOfMatchesForXpath(subSenseOneOne, 1);
        }