public void ResolvesMergedGenericType() { ManagedDictionary parent = new ManagedDictionary(); parent.Add("one", 1); parent.Add("two", 2); parent.KeyTypeName = "string"; parent.ValueTypeName = "int"; ManagedDictionary child = new ManagedDictionary(); child.MergeEnabled = true; child.Add("one", -1); child.Add("three", 3); ManagedDictionary merged = (ManagedDictionary)child.Merge(parent); IDictionary resolved = (IDictionary)merged.Resolve("somename", new RootObjectDefinition(typeof(object)), "prop", (name, definition, argumentName, element) => element); Assert.IsInstanceOf <IDictionary <string, int> >(resolved); Assert.AreEqual(3, resolved.Count); Assert.AreEqual(typeof(int), resolved["two"].GetType()); Assert.AreEqual(-1, resolved["one"]); }
public void ResolvesInternalGenericTypes() { ManagedDictionary dict2 = new ManagedDictionary(); dict2.Add("1", "stringValue"); dict2.KeyTypeName = "int"; dict2.ValueTypeName = typeof(InternalType).FullName; IDictionary resolved = (IDictionary)dict2.Resolve("other", new RootObjectDefinition(typeof(object)), "prop", delegate(string name, IObjectDefinition definition, string argumentName, object element) { if ("stringValue".Equals(element)) { return(new InternalType()); } return(element); } ); Assert.AreEqual(typeof(InternalType), resolved[1].GetType()); }
public void ResolvesGenericTypeNames() { ManagedDictionary dict = new ManagedDictionary(); dict.Add("key", "value"); dict.KeyTypeName = "string"; dict.ValueTypeName = "System.Collections.Generic.List<[string]>"; IDictionary resolved = (IDictionary)dict.Resolve("somename", new RootObjectDefinition(typeof(object)), "prop", delegate(string name, IObjectDefinition definition, string argumentName, object element) { if ("value".Equals(element)) { return(new List <string>()); } return(element); } ); Assert.AreEqual(1, resolved.Count); Assert.AreEqual(typeof(List <string>), resolved["key"].GetType()); }