Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Util
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17585/Spring/Spring.Core.Tests/Util
Modified Files:
StringUtilTestSuite.cs
Added Files:
TypeResolverTests.cs
Log Message:
Unit tests for the all of the new classes added in the previous commit.
--- NEW FILE: TypeResolverTests.cs ---
#region Licence
/*
* Copyright 2004 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
#region Imports
using System;
using NUnit.Framework;
#endregion
namespace Spring.Util {
/// <summary>
/// Unit tests for the TypeResolver class.
/// </summary>
/// <author>Rick Evans (.NET)</author>
/// <version>$Id: TypeResolverTests.cs,v 1.1 2004/07/26 07:43:10 springboy Exp $</version>
[TestFixture]
public class TypeResolverTests {
[Test]
public void ResolveLocalAssemblyType () {
Type t = new TypeResolver ().Resolve ("Spring.Objects.TestObject");
Assert.AreEqual (typeof (Spring.Objects.TestObject), t);
}
[Test]
public void ResolveWithPartialAssemblyName ()
{
Type t = new TypeResolver ().Resolve ("System.Data.IDbConnection, System.Data");
Assert.AreEqual (typeof (System.Data.IDbConnection), t);
}
[Test]
public void ResolveAliasedType ()
{
Type t = new TypeResolver ().Resolve ("string");
Assert.AreEqual (typeof (string), t);
}
/// <summary>
/// Tests that the resolve method throws the correct exception
/// when supplied a load of old rubbish as a type name.
/// </summary>
[Test]
[ExpectedException (typeof (TypeLoadException))]
public void ResolveRaskolnikovsDilemma ()
{
Type t = new TypeResolver ().Resolve ("RaskolnikovsDilemma, System.StPetersburg");
}
[Test]
[ExpectedException (typeof (TypeLoadException), "Could not load type with a null or zero length parameter.")]
public void ResolveBadArgs ()
{
Type t = new TypeResolver ().Resolve (null);
}
}
}
Index: StringUtilTestSuite.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Core.Tests/Util/StringUtilTestSuite.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** StringUtilTestSuite.cs 1 May 2004 06:15:43 -0000 1.3
--- StringUtilTestSuite.cs 26 Jul 2004 07:43:10 -0000 1.4
***************
*** 1,11 ****
/*
* Copyright 2002-2004 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,
--- 1,13 ----
+ #region Licence
+
/*
* Copyright 2002-2004 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,
***************
*** 13,36 ****
* See the License for the specific language governing permissions and
* limitations under the License.
! */
using System;
using NUnit.Framework;
namespace Spring.Util
{
! /// <summary>
! /// Test StringUtils functionality.
! /// </summary>
! /// <author>Aleksandar Seovic</author>
! /// <version>$Id$</version>
! [TestFixture]
public class StringUtilTestSuite
! {
! public StringUtilTestSuite()
! {
! }
!
/// <summary>
! /// Tests StringUtils.CountOccurrencesOf
/// </summary>
[Test]
--- 15,42 ----
* See the License for the specific language governing permissions and
* limitations under the License.
! */
!
! #endregion
!
! #region Imports
!
using System;
using NUnit.Framework;
+ #endregion
+
namespace Spring.Util
{
! /// <summary>
! /// Test StringUtils functionality.
! /// </summary>
! /// <author>Aleksandar Seovic</author>
! /// <author>Rick Evans (.NET)</author>
! /// <version>$Id$</version>
! [TestFixture]
public class StringUtilTestSuite
! {
/// <summary>
! /// Tests StringUtils.CountOccurrencesOf.
/// </summary>
[Test]
***************
*** 50,54 ****
/// <summary>
! /// Tests StringUtils.Delete
/// </summary>
[Test]
--- 56,60 ----
/// <summary>
! /// Tests StringUtils.Delete.
/// </summary>
[Test]
***************
*** 69,73 ****
/// <summary>
! /// Tests StringUtils.DeleteAny
/// </summary>
[Test]
--- 75,79 ----
/// <summary>
! /// Tests StringUtils.DeleteAny.
/// </summary>
[Test]
***************
*** 88,92 ****
/// <summary>
! /// Tests StringUtils.Split
/// </summary>
[Test]
--- 94,98 ----
/// <summary>
! /// Tests StringUtils.Split.
/// </summary>
[Test]
***************
*** 110,114 ****
/// <summary>
! /// Tests StringUtils.HasLength
/// </summary>
[Test]
--- 116,120 ----
/// <summary>
! /// Tests StringUtils.HasLength.
/// </summary>
[Test]
***************
*** 122,126 ****
/// <summary>
! /// Tests StringUtils.HasText
/// </summary>
[Test]
--- 128,132 ----
/// <summary>
! /// Tests StringUtils.HasText.
/// </summary>
[Test]
***************
*** 135,139 ****
/// <summary>
! /// Tests StringUtils.Unqualify
/// </summary>
[Test]
--- 141,145 ----
/// <summary>
! /// Tests StringUtils.Unqualify.
/// </summary>
[Test]
***************
*** 147,151 ****
/// <summary>
! /// Tests StringUtils.Uncapitalize
/// </summary>
[Test]
--- 153,157 ----
/// <summary>
! /// Tests StringUtils.Uncapitalize.
/// </summary>
[Test]
***************
*** 159,162 ****
--- 165,221 ----
}
+ /// <summary>
+ /// Tests StringUtils.AddStringToArray.
+ /// </summary>
+ [Test]
+ public void AddStringToArrayTests ()
+ {
+ string [] arr = new string [] {"Foo", "Bar"};
+ string [] res1 = new string [] {"Foo", "Bar", "Baz"};
+
+ Assert.IsTrue (
+ ArrayUtils.AreEqual (res1, StringUtils.AddStringToArray (arr, "Baz")));
+ Assert.IsTrue (
+ ArrayUtils.AreEqual (arr, StringUtils.AddStringToArray (arr, null)), "Added null string, so should've got the original array back.");
+ }
+
+ /// <summary>
+ /// Tests StringUtils.CollectionToDelimitedString.
+ /// </summary>
+ [Test]
+ public void CollectionToDelimitedString ()
+ {
+ Foo [] arr = new Foo [] {new Foo ("Foo"), new Foo ("Bar")};
+ Assert.AreEqual (
+ ":Foo,:Bar", StringUtils.CollectionToCommaDelimitedString (arr));
+ }
+
+ /// <summary>
+ /// Tests StringUtils.CollectionToDelimitedString.
+ /// </summary>
+ [Test]
+ public void ArrayToDelimitedString ()
+ {
+ Foo [] arr = new Foo [] {new Foo ("Foo"), new Foo ("Bar")};
+ Assert.AreEqual (
+ ":Foo,:Bar", StringUtils.ArrayToCommaDelimitedString (arr));
+ Assert.AreEqual ("null", StringUtils.ArrayToCommaDelimitedString (null));
+ }
+
+ private class Foo
+ {
+
+ public Foo (string bar)
+ {
+ _bar = bar;
+ }
+
+ public override string ToString ()
+ {
+ return ":" + _bar;
+ }
+
+ private string _bar;
+ }
}
}
|