Ejemplo n.º 1
0
        public void CanDeepClone()
        {
            var option = new DictionaryNodeListOptions.DictionaryNodeOption {
                Id = "option id", IsEnabled = true
            };
            var options = new DictionaryNodeListOptions {
                Options = new List <DictionaryNodeListOptions.DictionaryNodeOption> {
                    option
                }
            };
            var parent = new ConfigurableDictionaryNode();
            var child  = new ConfigurableDictionaryNode {
                Before = "before", IsEnabled = true, CSSClassNameOverride = "class", Parent = parent
            };
            var grandchild = new ConfigurableDictionaryNode {
                Between = "childBetween", FieldDescription = "FieldDesc", Parent = child
            };
            var grandsibling = new ConfigurableDictionaryNode {
                DictionaryNodeOptions = options, Style = "stylish", LabelSuffix = "1", Parent = parent
            };

            parent.Children = new List <ConfigurableDictionaryNode> {
                child
            };
            child.Children = new List <ConfigurableDictionaryNode> {
                grandchild, grandsibling
            };
            // SUT
            var clone = child.DeepCloneUnderSameParent();

            VerifyDuplication(clone, child);
        }
Ejemplo n.º 2
0
        public void ChildlessCanDeepClone()
        {
            var parent = new ConfigurableDictionaryNode();
            var child  = new ConfigurableDictionaryNode {
                After = "after", IsEnabled = true, SubField = "sub", IsCustomField = true, HideCustomFields = true, Parent = parent
            };

            parent.Children = new List <ConfigurableDictionaryNode> {
                child
            };
            // SUT
            var clone = child.DeepCloneUnderSameParent();

            VerifyDuplication(clone, child);
        }
Ejemplo n.º 3
0
        public void DuplicateSharedNodeDeepClones()
        {
            var sharedChild = new ConfigurableDictionaryNode {
                Label = "kid"
            };
            var sharedItem = new ConfigurableDictionaryNode {
                Label = "Shared", Children = new List <ConfigurableDictionaryNode> {
                    sharedChild
                }
            };
            var masterParent = new ConfigurableDictionaryNode
            {
                ReferenceItem = "Shared", ReferencedNode = sharedItem,
                Children      = new List <ConfigurableDictionaryNode>()      // just because we haven't any doesn't mean the list is null!
            };
            var clone = masterParent.DeepCloneUnderSameParent();             // SUT

            Assert.Null(clone.ReferenceItem);
            Assert.Null(clone.ReferencedNode);
            VerifyDuplicationList(clone.Children, masterParent.ReferencedOrDirectChildren, clone);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates a DictionaryConfigurationModel with one Main and one of each neeeded Minor Entry nodes, all with enabled HeadWord children
        /// </summary>
        internal static DictionaryConfigurationModel CreateInterestingConfigurationModel(LcmCache cache, PropertyTable propertyTable        = null,
                                                                                         DictionaryConfigurationModel.ConfigType configType = DictionaryConfigurationModel.ConfigType.Root)
        {
            var mainHeadwordNode = new ConfigurableDictionaryNode
            {
                FieldDescription      = "HeadWord",
                CSSClassNameOverride  = "entry",
                DictionaryNodeOptions = GetWsOptionsForLanguages(new[] { "fr" }),
                Before = "MainEntry: ",
            };
            var subEntryNode = new ConfigurableDictionaryNode
            {
                Children = new List <ConfigurableDictionaryNode> {
                    mainHeadwordNode
                },
                FieldDescription = "Subentries"
            };
            var mainEntryNode = new ConfigurableDictionaryNode
            {
                Children = new List <ConfigurableDictionaryNode> {
                    mainHeadwordNode
                },
                FieldDescription = "LexEntry"
            };

            if (configType == DictionaryConfigurationModel.ConfigType.Hybrid || configType == DictionaryConfigurationModel.ConfigType.Root)
            {
                mainEntryNode.Children.Add(subEntryNode);
            }
            if (configType == DictionaryConfigurationModel.ConfigType.Hybrid || configType == DictionaryConfigurationModel.ConfigType.Lexeme)
            {
                mainEntryNode.DictionaryNodeOptions = GetFullyEnabledListOptions(cache, DictionaryNodeListOptions.ListIds.Complex);
            }

            CssGeneratorTests.PopulateFieldsForTesting(mainEntryNode);

            var minorEntryNode = mainEntryNode.DeepCloneUnderSameParent();

            minorEntryNode.CSSClassNameOverride = "minorentry";
            minorEntryNode.Before = "MinorEntry: ";
            minorEntryNode.DictionaryNodeOptions = GetFullyEnabledListOptions(cache, DictionaryNodeListOptions.ListIds.Complex);

            var minorSecondNode = minorEntryNode.DeepCloneUnderSameParent();

            minorSecondNode.Before = "HalfStep: ";
            minorSecondNode.DictionaryNodeOptions = GetFullyEnabledListOptions(cache, DictionaryNodeListOptions.ListIds.Variant);

            var model = new DictionaryConfigurationModel
            {
                AllPublications = true,
                Parts           = new List <ConfigurableDictionaryNode> {
                    mainEntryNode, minorEntryNode, minorSecondNode
                },
                FilePath = propertyTable == null ? null : Path.Combine(DictionaryConfigurationListener.GetProjectConfigurationDirectory(propertyTable),
                                                                       "filename" + DictionaryConfigurationModel.FileExtension),
                IsRootBased = configType == DictionaryConfigurationModel.ConfigType.Root
            };

            if (configType != DictionaryConfigurationModel.ConfigType.Root)
            {
                model.Parts.Remove(minorEntryNode);
            }

            return(model);
        }