Update of /cvsroot/springnet/Spring.Net/test/Spring/Spring.Web.Tests/Objects/Factory/Support
In directory sc8-pr-cvs8.sourceforge.net:/tmp/cvs-serv17996
Modified Files:
WebObjectFactoryTests.cs
Log Message:
added first WebObjectFactory tests
Index: WebObjectFactoryTests.cs
===================================================================
RCS file: /cvsroot/springnet/Spring.Net/test/Spring/Spring.Web.Tests/Objects/Factory/Support/WebObjectFactoryTests.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** WebObjectFactoryTests.cs 18 May 2006 21:37:53 -0000 1.2
--- WebObjectFactoryTests.cs 15 Dec 2007 21:22:04 -0000 1.3
***************
*** 23,26 ****
--- 23,29 ----
using System;
using NUnit.Framework;
+ using Spring.Objects.Factory.Config;
+ using Spring.TestSupport;
+ using Spring.Web.TestSupport;
#endregion
***************
*** 28,39 ****
namespace Spring.Objects.Factory.Support
{
! /// <summary>
! /// Unit tests for the WebObjectFactory class.
! /// </summary>
! /// <author>Rick Evans</author>
! /// <version>$Id$</version>
! [TestFixture]
! public sealed class WebObjectFactoryTests
! {
! }
}
\ No newline at end of file
--- 31,85 ----
namespace Spring.Objects.Factory.Support
{
! /// <summary>
! /// Unit tests for the WebObjectFactory class.
! /// </summary>
! /// <author>Rick Evans</author>
! /// <version>$Id$</version>
! [TestFixture]
! public sealed class WebObjectFactoryTests
! {
! [Test, Explicit]
! public void CanBeUsedOnNonWebThread()
! {
! WebObjectFactory wof;
! RootWebObjectDefinition rwod;
!
! using (new VirtualEnvironmentMock("/somedir/some.file", "/", true))
! {
! wof = new WebObjectFactory("/somedir/", false);
! }
!
! rwod = new RootWebObjectDefinition(typeof(object), new ConstructorArgumentValues(), new MutablePropertyValues());
! rwod.Scope = ObjectScope.Application;
! wof.RegisterObjectDefinition("applicationScopedObject", rwod);
!
! rwod = new RootWebObjectDefinition(typeof(object), new ConstructorArgumentValues(), new MutablePropertyValues());
! rwod.Scope = ObjectScope.Request;
! wof.RegisterObjectDefinition("requestScopedObject", rwod);
!
! rwod = new RootWebObjectDefinition(typeof(object), new ConstructorArgumentValues(), new MutablePropertyValues());
! rwod.Scope = ObjectScope.Session;
! wof.RegisterObjectDefinition("sessionScopedObject", rwod);
!
! object o;
! o = wof.GetObject("applicationScopedObject");
! Assert.IsNotNull(o);
!
! AssertGetObjectThrows(typeof(InvalidOperationException), wof, "requestScopedObject");
! AssertGetObjectThrows(typeof(InvalidOperationException), wof, "sessionScopedObject");
! }
!
! private void AssertGetObjectThrows(Type exceptionType, WebObjectFactory wof, string objectName)
! {
! try
! {
! wof.GetObject(objectName);
! Assert.Fail("must not reach this line");
! }
! catch (Exception ex)
! {
! Assert.AreEqual(exceptionType, ex.GetType());
! }
! }
! }
}
\ No newline at end of file
|