From 3ab0ff9428e0b85bbc73285102ea7a6c4dadae68 Mon Sep 17 00:00:00 2001 From: Dmitrii Bardakov Date: Sun, 20 Oct 2013 01:25:59 -0700 Subject: [PATCH] Added test method for merged generic dictionary --- .../Factory/Support/ManagedDictionaryTests.cs | 53 ++++++++++++++----- 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/test/Spring/Spring.Core.Tests/Objects/Factory/Support/ManagedDictionaryTests.cs b/test/Spring/Spring.Core.Tests/Objects/Factory/Support/ManagedDictionaryTests.cs index d0fdc81c..570d4155 100644 --- a/test/Spring/Spring.Core.Tests/Objects/Factory/Support/ManagedDictionaryTests.cs +++ b/test/Spring/Spring.Core.Tests/Objects/Factory/Support/ManagedDictionaryTests.cs @@ -1,19 +1,19 @@ #region License -/* - * Copyright 2002-2010 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. +/* + * Copyright 2002-2010 the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ #endregion @@ -146,5 +146,30 @@ namespace Spring.Objects.Factory.Support Assert.AreEqual(1, resolved.Count); Assert.AreEqual(typeof(List), resolved["key"].GetType()); } + + [Test] + 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>(resolved); + Assert.AreEqual(3, resolved.Count); + Assert.AreEqual(typeof(int), resolved["two"].GetType()); + Assert.AreEqual(-1, resolved["one"]); + } } }