From f7b5da302e5975988f2d48916cf371fd789d37f0 Mon Sep 17 00:00:00 2001 From: eeichinger Date: Mon, 9 Mar 2009 23:57:00 +0000 Subject: [PATCH] fixed WebObjectDefinition Scope/ObjectScope handling --- .../Objects/Factory/Support/ObjectScope.cs | 12 +++- .../Support/WebObjectDefinitionTests.cs | 66 +++++++++++++++++++ .../Spring.Web.Tests.2008.csproj | 1 + 3 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 test/Spring/Spring.Web.Tests/Objects/Factory/Support/WebObjectDefinitionTests.cs diff --git a/src/Spring/Spring.Web/Objects/Factory/Support/ObjectScope.cs b/src/Spring/Spring.Web/Objects/Factory/Support/ObjectScope.cs index 51ab88ca..fb3ea393 100644 --- a/src/Spring/Spring.Web/Objects/Factory/Support/ObjectScope.cs +++ b/src/Spring/Spring.Web/Objects/Factory/Support/ObjectScope.cs @@ -26,10 +26,15 @@ namespace Spring.Objects.Factory.Support /// Aleksandar Seovic public enum ObjectScope { + /// + /// + /// + Singleton = 0, + /// /// Application scope. /// - Application = 0, + Application = Singleton, /// /// Session scope. @@ -41,6 +46,11 @@ namespace Spring.Objects.Factory.Support /// Request = 2, + /// + /// + /// + Prototype = -1, + /// /// Default scope (currently /// ). diff --git a/test/Spring/Spring.Web.Tests/Objects/Factory/Support/WebObjectDefinitionTests.cs b/test/Spring/Spring.Web.Tests/Objects/Factory/Support/WebObjectDefinitionTests.cs new file mode 100644 index 00000000..57689d90 --- /dev/null +++ b/test/Spring/Spring.Web.Tests/Objects/Factory/Support/WebObjectDefinitionTests.cs @@ -0,0 +1,66 @@ +#region License + +/* + * Copyright 2002-2009 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 + +using System; +using NUnit.Framework; +using Spring.Objects.Factory.Config; + +namespace Spring.Objects.Factory.Support +{ + /// + /// + /// Erich Eichinger + [TestFixture] + public class WebObjectDefinitionTests + { + [Test] + public void UnderstandsObjectScopeSingleton() + { + RootWebObjectDefinition rwod = new RootWebObjectDefinition(typeof(object), new ConstructorArgumentValues(), new MutablePropertyValues()); + rwod.IsSingleton = true; + Assert.IsFalse(rwod.IsPage); + Assert.IsTrue(rwod.IsSingleton); + Assert.IsFalse(rwod.IsPrototype); + Assert.AreEqual(ObjectScope.Singleton, ((IWebObjectDefinition)rwod).Scope); + Assert.AreEqual(ObjectScope.Application, ((IWebObjectDefinition)rwod).Scope); + } + + [Test] + public void UnderstandsObjectScopePrototype() + { + RootWebObjectDefinition rwod = new RootWebObjectDefinition(typeof(object), new ConstructorArgumentValues(), new MutablePropertyValues()); + rwod.IsSingleton = false; + Assert.IsFalse(rwod.IsPage); + Assert.IsFalse(rwod.IsSingleton); + Assert.IsTrue(rwod.IsPrototype); + Assert.AreEqual(ObjectScope.Prototype, ((IWebObjectDefinition)rwod).Scope); + } + +// [Test] +// public void UnderstandsObjectScopeForPages() +// { +// RootWebObjectDefinition rwod = new RootWebObjectDefinition("pagename.aspx", new MutablePropertyValues()); +// Assert.IsTrue(rwod.IsPage); +// Assert.IsFalse(rwod.IsSingleton); +// Assert.IsTrue(rwod.IsPrototype); +// Assert.AreEqual(ObjectScope.Prototype, ((IWebObjectDefinition)rwod).Scope); +// } + } +} \ No newline at end of file diff --git a/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2008.csproj b/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2008.csproj index f9b3a7b1..23418874 100644 --- a/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2008.csproj +++ b/test/Spring/Spring.Web.Tests/Spring.Web.Tests.2008.csproj @@ -100,6 +100,7 @@ + Code