SPRNET-444

SPRNET-1140
This commit is contained in:
eeichinger
2008-12-20 01:21:02 +00:00
parent 75e2f997bd
commit 044e8af105
17 changed files with 1885 additions and 1355 deletions

View File

@@ -48,7 +48,7 @@ namespace Spring.Core.TypeResolution
public void ResolveLocalAssemblyGenericType()
{
Type t = GetTypeResolver().Resolve("Spring.Objects.TestGenericObject< int, string>");
Assert.AreEqual(typeof(TestGenericObject<int,string>), t);
Assert.AreEqual(typeof(TestGenericObject<int, string>), t);
}
[Test]
@@ -74,6 +74,26 @@ namespace Spring.Core.TypeResolution
Assert.AreEqual(typeof(System.Collections.Generic.Stack<string>), t);
}
[Test]
public void ResolveGenericArrayType()
{
Type t = GetTypeResolver().Resolve("System.Nullable<[System.Int32, mscorlib]>[,]");
Assert.AreEqual(typeof(int?[,]), t);
t = GetTypeResolver().Resolve("System.Nullable`1[int][,]");
Assert.AreEqual(typeof(int?[,]), t);
}
[Test]
public void ResolveGenericArrayTypeWithAssemblyName()
{
Type t = GetTypeResolver().Resolve("System.Nullable<[System.Int32, mscorlib]>[,], mscorlib");
Assert.AreEqual(typeof(int?[,]), t);
t = GetTypeResolver().Resolve("System.Nullable<[System.Int32, mscorlib]>[,], mscorlib");
Assert.AreEqual(typeof(int?[,]), t);
t = GetTypeResolver().Resolve("System.Nullable`1[[System.Int32, mscorlib]][,], mscorlib");
Assert.AreEqual(typeof(int?[,]), t);
}
[Test]
[ExpectedException(typeof(TypeLoadException))]
public void ResolveAmbiguousGenericTypeWithAssemblyName()
@@ -87,6 +107,27 @@ namespace Spring.Core.TypeResolution
{
Type t = GetTypeResolver().Resolve("Spring.Objects.TestGenericObject<int, <string>>");
}
[Test]
public void ResolveNestedGenericTypeWithAssemblyName()
{
Type t = GetTypeResolver().Resolve("System.Collections.Generic.Stack< Spring.Objects.TestGenericObject<int, string> >, System");
Assert.AreEqual(typeof(System.Collections.Generic.Stack<Spring.Objects.TestGenericObject<int, string>>), t);
}
[Test]
public void ResolveClrNotationStyleGenericTypeWithAssemblyName()
{
Type t = GetTypeResolver().Resolve("System.Collections.Generic.Stack`1[ [Spring.Objects.TestGenericObject`2[int, string], Spring.Core.Tests] ], System");
Assert.AreEqual(typeof(System.Collections.Generic.Stack<Spring.Objects.TestGenericObject<int, string>>), t);
}
[Test]
public void ResolveNestedQuotedGenericTypeWithAssemblyName()
{
Type t = GetTypeResolver().Resolve("System.Collections.Generic.Stack< [Spring.Objects.TestGenericObject<int, string>, Spring.Core.Tests] >, System");
Assert.AreEqual(typeof(System.Collections.Generic.Stack<Spring.Objects.TestGenericObject<int, string>>), t);
}
}
}

View File

@@ -703,12 +703,33 @@ namespace Spring.Expressions
/// Tests type node
/// </summary>
[Test]
[Ignore("does not work yet due to parser expecting ID production within T(ID)")]
// [Ignore("does not work yet due to parser expecting ID production within T(ID)")]
public void TestTypeNodeWithAssemblyQualifiedName()
{
Assert.AreEqual(typeof(ExpressionEvaluator), ExpressionEvaluator.GetValue(null, string.Format("T({0})", typeof(ExpressionEvaluator).AssemblyQualifiedName)));
}
#if NET_2_0
/// <summary>
/// Tests type node
/// </summary>
[Test]
public void TestTypeNodeWithGenericAssemblyQualifiedName()
{
// Assert.AreEqual(typeof(int?), ExpressionEvaluator.GetValue(null, "T(System.Nullable`1[System.Int32], mscorlib)"));
// Assert.AreEqual(typeof(int?), ExpressionEvaluator.GetValue(null, "T(System.Nullable`1[[System.Int32, mscorlib]], mscorlib)"));
Assert.AreEqual(typeof(int?), ExpressionEvaluator.GetValue(null, "T(System.Nullable`1[[int]], mscorlib)"));
}
/// <summary>
/// Tests type node
/// </summary>
[Test]
public void TestTypeNodeWithGenericAssemblyQualifiedArrayName()
{
Assert.AreEqual(typeof(int?[,]), ExpressionEvaluator.GetValue(null, "T(System.Nullable`1[[System.Int32, mscorlib]][,], mscorlib)"));
}
#endif
/// <summary>
/// Tests constructor node
/// </summary>
@@ -1519,6 +1540,10 @@ namespace Spring.Expressions
Assert.AreEqual(typeof(TestObject),
ExpressionEvaluator.GetValue(null, "@(myContext:goran)").GetType());
// string literals allowed for contextname
Assert.AreEqual(typeof(TestObject),
ExpressionEvaluator.GetValue(null, "@('myContext':goran)").GetType());
}
/// <summary>
@@ -1560,6 +1585,8 @@ namespace Spring.Expressions
ctx.Name = "my.Context";
ContextRegistry.RegisterContext(ctx);
Assert.AreEqual(typeof(TestObject),
ExpressionEvaluator.GetValue(null, "@(my.Context:goran)").GetType());
Assert.AreEqual(typeof(TestObject),
ExpressionEvaluator.GetValue(null, "@(my\\.Context:goran)").GetType());
}

View File

@@ -1,8 +1,7 @@
#if NET_2_0
#region License
/*
* Copyright 2002-2004 the original author or authors.
* Copyright 2002-2008 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.
@@ -19,6 +18,8 @@
#endregion
#if NET_2_0
#region Imports
using System;

View File

@@ -58,6 +58,31 @@ namespace Spring.Util
Assert.IsTrue(ArrayUtils.AreEqual(new string[] {"one"}, res = StringUtils.Split("one", delim, true, true)), "Received '" + String.Join(",", res) + "'");
}
[Test]
public void SplitWithQuotedStrings()
{
string[] expectedParts = new string[] { "a", "[test,<,>>[]]]", "asdf<,<,>,>aa" };
string testString = string.Join(",", expectedParts);
string[] result = StringUtils.Split(testString, ",", false, false, "[]<>");
Assert.AreEqual( expectedParts, result );
}
[Test]
public void SplitAddsEmptyStrings()
{
string testString = ",";
string[] result = StringUtils.Split(testString, ",", true, false, null);
Assert.AreEqual( new string[] { "", "" }, result );
}
[Test]
public void SplitAcceptsWhitespaceDelimiters()
{
string testString = "a\nb\tc d";
string[] result = StringUtils.Split(testString, "\n\t ", true, false, null);
Assert.AreEqual( new string[] { "a", "b", "c", "d" }, result );
}
[Test]
public void HasLengthTests()
{