public void MergeWithNonCompatibleParentType() { ManagedDictionary child = new ManagedDictionary(); child.MergeEnabled = true; child.Merge("hello"); }
public void MergeWithNullParent() { ManagedDictionary child = new ManagedDictionary(); child.MergeEnabled = true; Assert.AreSame(child, child.Merge(null)); }
public void MergeWithNonCompatibleParentType() { ManagedDictionary child = new ManagedDictionary(); child.MergeEnabled = true; Assert.Throws <InvalidOperationException>(() => child.Merge("hello")); }
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 MergeEmptyChild() { ManagedDictionary parent = new ManagedDictionary(); parent.Add("one", "one"); parent.Add("two", "two"); ManagedDictionary child = new ManagedDictionary(); child.MergeEnabled = true; IDictionary mergedMap = (IDictionary)child.Merge(parent); Assert.AreEqual(2, mergedMap.Count); }
public void MergeSunnyDay() { ManagedDictionary parent = new ManagedDictionary(); parent.Add("one", "one"); parent.Add("two", "two"); ManagedDictionary child = new ManagedDictionary(); child.Add("three", "three"); child.MergeEnabled = true; IDictionary mergedList = (IDictionary)child.Merge(parent); Assert.AreEqual(3, mergedList.Count); }
public void MergeChildValueOverrideTheParents() { ManagedDictionary parent = new ManagedDictionary(); parent.Add("one", "one"); parent.Add("two", "two"); ManagedDictionary child = new ManagedDictionary(); child.Add("one", "fork"); child.MergeEnabled = true; IDictionary mergedMap = (IDictionary)child.Merge(parent); Assert.AreEqual(2, mergedMap.Count); Assert.AreEqual("fork", mergedMap["one"]); }
public void MergeNotAllowedWhenMergeNotEnabled() { ManagedDictionary child = new ManagedDictionary(); child.Merge(null); }
public void MergeNotAllowedWhenMergeNotEnabled() { ManagedDictionary child = new ManagedDictionary(); Assert.Throws <InvalidOperationException>(() => child.Merge(null), "Not allowed to merge when the 'MergeEnabled' property is set to 'false'"); }