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); }
public void CanDeepCloneListOptions() { var orig = new DictionaryNodeListOptions { ListId = DictionaryNodeListOptions.ListIds.Sense, Options = new List <DictionaryNodeListOptions.DictionaryNodeOption> { new DictionaryNodeListOptions.DictionaryNodeOption { Id = "Optn1", IsEnabled = true }, new DictionaryNodeListOptions.DictionaryNodeOption { Id = "Optn2", IsEnabled = false }, new DictionaryNodeListOptions.DictionaryNodeOption { Id = "Optn3", IsEnabled = true }, } }; // SUT var genericClone = orig.DeepClone(); var clone = genericClone as DictionaryNodeListOptions; Assert.NotNull(clone, "Incorrect subclass returned; expected DictionaryNodeListOptions"); Assert.Null(clone as DictionaryNodeListAndParaOptions, "Incorrect subclass returned; did not expect DictionaryNodeListAndParaOptions"); Assert.AreNotSame(orig, clone, "Not deep cloned; shallow cloned"); Assert.AreEqual(orig.ListId, clone.ListId); AssertListWasDeepCloned(orig.Options, clone.Options); }
public static DictionaryNodeOptions GetListOptionsForStrings(DictionaryNodeListOptions.ListIds listName, IEnumerable <string> checkedItems) { var listOptions = new DictionaryNodeListOptions { ListId = listName, Options = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(checkedItems) }; return(listOptions); }
public static DictionaryNodeOptions GetListOptionsForItems(DictionaryNodeListOptions.ListIds listName, ICmPossibility[] checkedItems) { var listOptions = new DictionaryNodeListOptions { ListId = listName, Options = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings(checkedItems.Select(id => id.Guid.ToString()).ToList()) }; return(listOptions); }
public static DictionaryNodeOptions GetFullyEnabledListOptions(LcmCache cache, DictionaryNodeListOptions.ListIds listName) { List <DictionaryNodeListOptions.DictionaryNodeOption> dnoList; var useParaOptions = false; switch (listName) { case DictionaryNodeListOptions.ListIds.Minor: dnoList = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings( new[] { XmlViewsUtils.GetGuidForUnspecifiedVariantType(), XmlViewsUtils.GetGuidForUnspecifiedComplexFormType() } .Select(guid => guid.ToString()) .Union(cache.LangProject.LexDbOA.ComplexEntryTypesOA.PossibilitiesOS .Union(cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS).Select(item => item.Guid.ToString()))); break; case DictionaryNodeListOptions.ListIds.Variant: dnoList = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings( new[] { XmlViewsUtils.GetGuidForUnspecifiedVariantType().ToString() } .Union(cache.LangProject.LexDbOA.VariantEntryTypesOA.PossibilitiesOS.Select(item => item.Guid.ToString()))); break; case DictionaryNodeListOptions.ListIds.Complex: useParaOptions = true; dnoList = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings( new[] { XmlViewsUtils.GetGuidForUnspecifiedComplexFormType().ToString() } .Union(cache.LangProject.LexDbOA.ComplexEntryTypesOA.PossibilitiesOS.Select(item => item.Guid.ToString()))); break; case DictionaryNodeListOptions.ListIds.Note: useParaOptions = true; dnoList = DictionaryDetailsControllerTests.ListOfEnabledDNOsFromStrings( new[] { XmlViewsUtils.GetGuidForUnspecifiedExtendedNoteType().ToString() } .Union(cache.LangProject.LexDbOA.ExtendedNoteTypesOA.PossibilitiesOS.Select(item => item.Guid.ToString()))); break; default: throw new NotImplementedException(string.Format("Unknown list id {0}", listName)); } DictionaryNodeListOptions listOptions = useParaOptions ? new DictionaryNodeListAndParaOptions() : new DictionaryNodeListOptions(); listOptions.ListId = listName; listOptions.Options = dnoList; return(listOptions); }