public void TryGetMasterParent() { var child = new ConfigurableDictionaryNode(); var sharedNode = new ConfigurableDictionaryNode { Label = "Shared", Children = new List <ConfigurableDictionaryNode> { child } }; var masterParent = new ConfigurableDictionaryNode { ReferenceItem = "Shared" }; var root = new ConfigurableDictionaryNode { Children = new List <ConfigurableDictionaryNode> { masterParent } }; CssGeneratorTests.PopulateFieldsForTesting(DictionaryConfigurationModelTests.CreateSimpleSharingModel(root, sharedNode)); ConfigurableDictionaryNode returnedMasterParent; Assert.True(child.TryGetMasterParent(out returnedMasterParent)); // SUT Assert.AreSame(masterParent, returnedMasterParent); Assert.False(masterParent.TryGetMasterParent(out returnedMasterParent), "The master parent doesn't *have* a master parent, it *is* one"); // SUT Assert.IsNull(returnedMasterParent, "Master Parent"); Assert.False(root.TryGetMasterParent(out returnedMasterParent), "The root node *certainly* doesn't have a master parent"); // SUT Assert.IsNull(returnedMasterParent, "Root Node"); }
public void BuildPathStringFromNode() { var subsenses = new ConfigurableDictionaryNode { Label = "Subsenses", FieldDescription = "SensesOS", ReferenceItem = "SharedSenses" }; var sharedSenses = new ConfigurableDictionaryNode { Label = "SharedSenses", FieldDescription = "SensesOS", Children = new List <ConfigurableDictionaryNode> { subsenses } }; var senses = new ConfigurableDictionaryNode { Label = "Senses", FieldDescription = "SensesOS", ReferenceItem = "SharedSenses" }; var mainEntry = new ConfigurableDictionaryNode { FieldDescription = "LexEntry", Children = new List <ConfigurableDictionaryNode> { senses } }; var model = DictionaryConfigurationModelTests.CreateSimpleSharingModel(mainEntry, sharedSenses); CssGeneratorTests.PopulateFieldsForTesting(model); // PopulateFieldsForTesting populates each node's Label with its FieldDescription Assert.AreEqual("LexEntry > Senses > SharedSenses > Subsenses", DictionaryConfigurationMigrator.BuildPathStringFromNode(subsenses)); Assert.AreEqual("LexEntry > Senses > Subsenses", DictionaryConfigurationMigrator.BuildPathStringFromNode(subsenses, false)); Assert.AreEqual("LexEntry", DictionaryConfigurationMigrator.BuildPathStringFromNode(mainEntry)); }
public void DuplicatesSharedGroupingNodeChildrenAffectSuffixes() { var nodeToDuplicateLabel = "node"; var nodeToDuplicate = new ConfigurableDictionaryNode { FieldDescription = nodeToDuplicateLabel }; var dupUnderShardGroup = new ConfigurableDictionaryNode { FieldDescription = nodeToDuplicateLabel, LabelSuffix = "1" }; var sharedNode = new ConfigurableDictionaryNode { Label = "Shared", Children = new List <ConfigurableDictionaryNode> { dupUnderShardGroup }, DictionaryNodeOptions = new DictionaryNodeGroupingOptions() }; var sharedGroupRefNode = new ConfigurableDictionaryNode { ReferenceItem = "Shared", DictionaryNodeOptions = new DictionaryNodeGroupingOptions() }; var root = new ConfigurableDictionaryNode { Children = new List <ConfigurableDictionaryNode> { sharedGroupRefNode, nodeToDuplicate } }; CssGeneratorTests.PopulateFieldsForTesting(DictionaryConfigurationModelTests.CreateSimpleSharingModel(root, sharedNode)); // SUT var duplicate = nodeToDuplicate.DuplicateAmongSiblings(); var inGroupDup = dupUnderShardGroup.DuplicateAmongSiblings(); Assert.That(duplicate.Label, Is.EqualTo(nodeToDuplicateLabel), "should not have changed original node label"); Assert.That(nodeToDuplicate.LabelSuffix, Is.Null, "should not have changed original node label suffix"); Assert.That(duplicate.LabelSuffix, Is.EqualTo("2"), "(1) was used in the group, so the suffix should be 2"); Assert.That(inGroupDup.LabelSuffix, Is.EqualTo("3"), "(2) was used in the group parent, so the suffix should be 3"); }