Пример #1
0
        public void CanDeepCloneSenseOptions()
        {
            var orig = new DictionaryNodeSenseOptions
            {
                BeforeNumber                 = "BeforeNumber",
                NumberingStyle               = "%O",
                AfterNumber                  = "AfterNumber",
                NumberStyle                  = "Dictionary-SenseNumber",
                NumberEvenASingleSense       = true,
                ShowSharedGrammarInfoFirst   = true,
                DisplayEachSenseInAParagraph = true,
                DisplayFirstSenseInline      = true
            };

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

            var clone = genericClone as DictionaryNodeSenseOptions;

            Assert.NotNull(clone, "Incorrect subclass returned; expected DictionaryNodeSenseOptions");
            Assert.AreNotSame(orig, clone, "Not deep cloned; shallow cloned");
            Assert.AreEqual(orig.BeforeNumber, clone.BeforeNumber);
            Assert.AreEqual(orig.NumberingStyle, clone.NumberingStyle);
            Assert.AreEqual(orig.AfterNumber, clone.AfterNumber);
            Assert.AreEqual(orig.NumberStyle, clone.NumberStyle);
            Assert.AreEqual(orig.NumberEvenASingleSense, clone.NumberEvenASingleSense);
            Assert.AreEqual(orig.ShowSharedGrammarInfoFirst, clone.ShowSharedGrammarInfoFirst);
            Assert.AreEqual(orig.DisplayEachSenseInAParagraph, clone.DisplayEachSenseInAParagraph);
            Assert.AreEqual(orig.DisplayFirstSenseInline, clone.DisplayFirstSenseInline);
        }
        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);
        }