예제 #1
0
        public void MergeWithNonCompatibleParentType()
        {
            ManagedDictionary child = new ManagedDictionary();

            child.MergeEnabled = true;
            child.Merge("hello");
        }
예제 #2
0
        public void MergeWithNullParent()
        {
            ManagedDictionary child = new ManagedDictionary();

            child.MergeEnabled = true;
            Assert.AreSame(child, child.Merge(null));
        }
예제 #3
0
        public void MergeWithNonCompatibleParentType()
        {
            ManagedDictionary child = new ManagedDictionary();

            child.MergeEnabled = true;
            Assert.Throws <InvalidOperationException>(() => child.Merge("hello"));
        }
예제 #4
0
        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"]);
        }
예제 #5
0
        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);
        }
예제 #6
0
        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);
        }
예제 #7
0
        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"]);
        }
예제 #8
0
        public void MergeNotAllowedWhenMergeNotEnabled()
        {
            ManagedDictionary child = new ManagedDictionary();

            child.Merge(null);
        }
예제 #9
0
        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'");
        }