public void MergeWithNonCompatibleParentType()
        {
            ManagedNameValueCollection child = new ManagedNameValueCollection();

            child.MergeEnabled = true;
            Assert.Throws <InvalidOperationException>(() => child.Merge("hello"));
        }
        public void MergeWithNullParent()
        {
            ManagedNameValueCollection child = new ManagedNameValueCollection();

            child.MergeEnabled = true;
            Assert.AreSame(child, child.Merge(null));
        }
        public void MergeWithNonCompatibleParentType()
        {
            ManagedNameValueCollection child = new ManagedNameValueCollection();

            child.MergeEnabled = true;
            child.Merge("hello");
        }
Example #4
0
        public object GetObject(IObjectDefinitionService objectDefinitionService)
        {
            ManagedNameValueCollection nameValueCollection = new ManagedNameValueCollection();

            foreach (var nameValueCollectionAction in _nameValueCollectionActions)
            {
                nameValueCollectionAction(nameValueCollection, objectDefinitionService);
            }

            return(nameValueCollection);
        }
        public void MergeEmptyChild()
        {
            ManagedNameValueCollection parent = new ManagedNameValueCollection();

            parent.Add("one", "one");
            parent.Add("two", "two");
            ManagedNameValueCollection child = new ManagedNameValueCollection();

            child.MergeEnabled = true;
            NameValueCollection mergedMap = (NameValueCollection)child.Merge(parent);

            Assert.AreEqual(2, mergedMap.Count);
        }
        public void MergeSunnyDay()
        {
            ManagedNameValueCollection parent = new ManagedNameValueCollection();

            parent.Add("one", "one");
            parent.Add("two", "two");
            ManagedNameValueCollection child = new ManagedNameValueCollection();

            child.Add("three", "three");
            child.MergeEnabled = true;
            NameValueCollection mergedList = (NameValueCollection)child.Merge(parent);

            Assert.AreEqual(3, mergedList.Count);
        }
        public void MergeChildValueOverrideTheParents()
        {
            ManagedNameValueCollection parent = new ManagedNameValueCollection();

            parent.Add("one", "one");
            parent.Add("two", "two");
            ManagedNameValueCollection child = new ManagedNameValueCollection();

            child.Add("one", "fork");
            child.MergeEnabled = true;
            NameValueCollection mergedMap = (NameValueCollection)child.Merge(parent);

            Assert.AreEqual(2, mergedMap.Count);
            Assert.AreEqual("fork", mergedMap["one"]);
        }
        public void MergeNotAllowedWhenMergeNotEnabled()
        {
            ManagedNameValueCollection child = new ManagedNameValueCollection();

            Assert.Throws <InvalidOperationException>(() => child.Merge(null), "Not allowed to merge when the 'MergeEnabled' property is set to 'false'");
        }
        public void MergeNotAllowedWhenMergeNotEnabled()
        {
            ManagedNameValueCollection child = new ManagedNameValueCollection();

            child.Merge(null);
        }