Added test method for merged generic dictionary

This commit is contained in:
Dmitrii Bardakov
2013-10-20 01:25:59 -07:00
parent aac001c707
commit 3ab0ff9428

View File

@@ -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<string>), 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<IDictionary<string,int>>(resolved);
Assert.AreEqual(3, resolved.Count);
Assert.AreEqual(typeof(int), resolved["two"].GetType());
Assert.AreEqual(-1, resolved["one"]);
}
}
}