upgraded to NUnitAspEx 2.0.3482.27831 - no nunit dependency anymore
This commit is contained in:
@@ -20,10 +20,6 @@
|
||||
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Web;
|
||||
using NUnit.Extensions.Asp.AspTester;
|
||||
using NUnit.Framework;
|
||||
using NUnitAspEx;
|
||||
using Spring.Objects.Factory;
|
||||
@@ -38,18 +34,24 @@ namespace Spring.Context.Support
|
||||
///
|
||||
/// </summary>
|
||||
/// <author>Erich Eichinger</author>
|
||||
[AspTestFixture("/Test", "/Spring/Context/Support/WebApplicationContextTests")]
|
||||
[TestFixture]
|
||||
public class WebApplicationContextTests : WebFormTestCase
|
||||
{
|
||||
public WebApplicationContextTests()
|
||||
: base("/Test", "/Spring/Context/Support/WebApplicationContextTests/")
|
||||
{}
|
||||
|
||||
[Test]
|
||||
public void CanAccessContextFromNonWebThread()
|
||||
{
|
||||
Host.Execute(new TestAction(CanAccessContextFromNonWebThreadImpl));
|
||||
}
|
||||
|
||||
public static void CanAccessContextFromNonWebThreadImpl()
|
||||
{
|
||||
IApplicationContext ctx;
|
||||
|
||||
using (TestWebContext requestContext = new TestWebContext("/Test", "/DoesNotExist.oaspx"))
|
||||
{
|
||||
ctx = WebApplicationContext.Current;
|
||||
}
|
||||
ctx = WebApplicationContext.GetRootContext();
|
||||
|
||||
AsyncTestMethod testMethod = new AsyncTestMethod(1, new AsyncTestMethod.TestMethod(DoBackgroundWork), ctx);
|
||||
testMethod.Start();
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
#region License
|
||||
|
||||
/*
|
||||
* Copyright <20> 2002-2007 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.Core.Extensibility;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Spring
|
||||
{
|
||||
/// <summary>
|
||||
/// Required for auto-registering NUnitAspEx extension with NUnit for this assembly
|
||||
/// </summary>
|
||||
/// <author>Erich Eichinger</author>
|
||||
[NUnitAddin]
|
||||
public class MyNUnitAddinHelper : NUnitAspEx.NUnitAddinHelper
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,7 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using NUnitAspEx;
|
||||
using NUnitAspEx.Core;
|
||||
using Spring.TestSupport;
|
||||
|
||||
#endregion
|
||||
@@ -33,9 +34,13 @@ namespace Spring.Objects.Factory.Support
|
||||
/// Unit tests for the WebObjectDefinitionFactory class.
|
||||
/// </summary>
|
||||
/// <author>Erich Eichinger</author>
|
||||
[AspTestFixture("/Test", "/Spring/Objects/Factory/Support")]
|
||||
public class WebObjectDefinitionFactoryTests
|
||||
[TestFixture]
|
||||
public class WebObjectDefinitionFactoryTests : WebApplicationTests
|
||||
{
|
||||
public WebObjectDefinitionFactoryTests()
|
||||
: base("/Test", "/Spring/Objects/Factory/Support")
|
||||
{}
|
||||
|
||||
[Test]
|
||||
public void CreateRootDefinition()
|
||||
{
|
||||
@@ -83,6 +88,11 @@ namespace Spring.Objects.Factory.Support
|
||||
|
||||
[Test]
|
||||
public void ResolvesToPageRootDefinitionIfEndsWithASPX()
|
||||
{
|
||||
Host.Execute(new TestAction(ResolvesToPageRootDefinitionIfEndsWithASPXImpl));
|
||||
}
|
||||
|
||||
public static void ResolvesToPageRootDefinitionIfEndsWithASPXImpl()
|
||||
{
|
||||
using (TestWebContext ctx = new TestWebContext("/Test", "testform.aspx"))
|
||||
{
|
||||
@@ -97,6 +107,11 @@ namespace Spring.Objects.Factory.Support
|
||||
|
||||
[Test]
|
||||
public void ResolvesToPageChildDefinitionIfEndsWithASPX()
|
||||
{
|
||||
Host.Execute(new TestAction(ResolvesToPageChildDefinitionIfEndsWithASPXImpl));
|
||||
}
|
||||
|
||||
public static void ResolvesToPageChildDefinitionIfEndsWithASPXImpl()
|
||||
{
|
||||
using (TestWebContext ctx = new TestWebContext("/Test", "testform.aspx"))
|
||||
{
|
||||
@@ -112,6 +127,11 @@ namespace Spring.Objects.Factory.Support
|
||||
[Test]
|
||||
[ExpectedException(typeof(ObjectCreationException))]
|
||||
public void ThrowsArgumentExceptionOnNonExistingPath()
|
||||
{
|
||||
Host.Execute(new TestAction(ThrowsArgumentExceptionOnNonExistingPathImpl));
|
||||
}
|
||||
|
||||
public static void ThrowsArgumentExceptionOnNonExistingPathImpl()
|
||||
{
|
||||
using (TestWebContext ctx = new TestWebContext("/Test", "testform.aspx"))
|
||||
{
|
||||
|
||||
@@ -98,7 +98,6 @@
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Globalization\Resolvers\DefaultWebCultureResolverTests.cs" />
|
||||
<Compile Include="MyNUnitAddinHelper.cs" />
|
||||
<Compile Include="Objects\Factory\Support\WebObjectDefinitionFactoryTests.cs" />
|
||||
<Compile Include="Objects\Factory\Support\WebObjectDefinitionTests.cs" />
|
||||
<Compile Include="Objects\Factory\Support\WebObjectFactoryTests.cs">
|
||||
@@ -115,6 +114,7 @@
|
||||
<Compile Include="TestSupport\TestWebContextTests.cs" />
|
||||
<Compile Include="TestSupport\VirtualEnvironmentMock.cs" />
|
||||
<Compile Include="TestSupport\VoidDelegate.cs" />
|
||||
<Compile Include="TestSupport\WebApplicationTests.cs" />
|
||||
<Compile Include="Threading\HttpContextStorageTests.cs" />
|
||||
<Compile Include="Threading\HybridContextStorageTests.cs" />
|
||||
<Compile Include="Util\WebDIPerformanceTests.cs" />
|
||||
@@ -161,7 +161,9 @@
|
||||
<Content Include="Data\Spring\Web\Support\PageHandlerFactoryTests\ReadOnlySession.aspx" />
|
||||
<Content Include="Data\Spring\Web\Support\PageHandlerFactoryTests\TransferAfterSetResult.aspx" />
|
||||
<Content Include="Data\Spring\Web\Support\PageHandlerFactoryTests\MaintainsSession1.aspx" />
|
||||
<Content Include="Data\Spring\Web\Support\PageHandlerFactoryTests\MaintainsSession2.aspx" />
|
||||
<Content Include="Data\Spring\Web\Support\PageHandlerFactoryTests\MaintainsSession2.aspx">
|
||||
<SubType>ASPXCodeBehind</SubType>
|
||||
</Content>
|
||||
<Content Include="Data\Spring\Web\Support\PageHandlerFactoryTests\DisablesSession.aspx" />
|
||||
<Content Include="Data\Spring\Web\Support\PageHandlerFactoryTests\TransferAfterSetResultSave.aspx" />
|
||||
<EmbeddedResource Include="Data\Spring\Web\Support\LocalResourceManagerTests\App_LocalResources\WithResources.aspx.resx" />
|
||||
|
||||
@@ -41,11 +41,14 @@ namespace Spring.TestSupport
|
||||
/// Base class for NUnitAsp test fixtures. Extend this class to use NUnitAsp.
|
||||
/// </summary>
|
||||
[TestFixture]
|
||||
public abstract class WebFormTestCase : CompatibilityAdapter
|
||||
public abstract class WebFormTestCase : WebApplicationTests
|
||||
{
|
||||
private bool setupCalled = false;
|
||||
|
||||
/// <summary>
|
||||
protected WebFormTestCase(string virtualPath, string relativePhysicalPath) : base(virtualPath, relativePhysicalPath)
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Do not call. For use by NUnit only.
|
||||
/// </summary>
|
||||
[SetUp]
|
||||
@@ -111,7 +114,7 @@ namespace Spring.TestSupport
|
||||
{
|
||||
if (!setupCalled)
|
||||
{
|
||||
Fail("A required setup method in WebFormTestCase was not called. This is probably because you used the [SetUp] attribute in a subclass of WebFormTestCase. That is not supported. Override the SetUp() method instead.");
|
||||
Assert.Fail("A required setup method in WebFormTestCase was not called. This is probably because you used the [SetUp] attribute in a subclass of WebFormTestCase. That is not supported. Override the SetUp() method instead.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
#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 NUnit.Framework;
|
||||
using NUnitAspEx;
|
||||
using NUnitAspEx.Core;
|
||||
|
||||
namespace Spring.TestSupport
|
||||
{
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <author>Erich Eichinger</author>
|
||||
public abstract class WebApplicationTests
|
||||
{
|
||||
private readonly string virtualPath;
|
||||
private readonly string relativePhysicalPath;
|
||||
private IAspFixtureHost host;
|
||||
|
||||
public IAspFixtureHost Host
|
||||
{
|
||||
get { return host; }
|
||||
}
|
||||
|
||||
protected WebApplicationTests(string virtualPath, string relativePhysicalPath)
|
||||
{
|
||||
this.virtualPath = virtualPath;
|
||||
this.relativePhysicalPath = relativePhysicalPath;
|
||||
}
|
||||
|
||||
[TestFixtureSetUp]
|
||||
public virtual void TestFixtureSetup()
|
||||
{
|
||||
host = AspFixtureHost.CreateInstance(virtualPath, relativePhysicalPath, this);
|
||||
}
|
||||
|
||||
[TestFixtureTearDown]
|
||||
public virtual void TestFixtureTearDown()
|
||||
{
|
||||
host = AspFixtureHost.ReleaseInstance(host);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,14 +18,10 @@
|
||||
|
||||
#endregion
|
||||
|
||||
#region Imports
|
||||
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using NUnit.Framework;
|
||||
using NUnitAspEx;
|
||||
|
||||
#endregion
|
||||
using NUnitAspEx.Client;
|
||||
using Spring.TestSupport;
|
||||
|
||||
#if NET_2_0
|
||||
|
||||
@@ -35,13 +31,17 @@ namespace Spring.Web.Support
|
||||
///
|
||||
/// </summary>
|
||||
/// <author>Erich Eichinger</author>
|
||||
[AspTestFixture("/Test", "/Spring/Web/Support/LocalResourceManagerTests")]
|
||||
public class LocalResourceManagerTests
|
||||
[TestFixture]
|
||||
public class LocalResourceManagerTests : WebApplicationTests
|
||||
{
|
||||
public LocalResourceManagerTests()
|
||||
: base("/Test", "/Spring/Web/Support/LocalResourceManagerTests")
|
||||
{}
|
||||
|
||||
[Test]
|
||||
public void ReturnsWithResources()
|
||||
{
|
||||
AspTestClient client = new AspTestClient();
|
||||
HttpWebClient client = Host.CreateWebClient();
|
||||
string result = client.GetPage("WithResources.aspx");
|
||||
Trace.Write(result);
|
||||
Assert.AreEqual("<span id=\"Result\">FromResource</span>", result);
|
||||
@@ -50,7 +50,7 @@ namespace Spring.Web.Support
|
||||
[Test]
|
||||
public void ReturnsWithoutResources()
|
||||
{
|
||||
AspTestClient client = new AspTestClient();
|
||||
HttpWebClient client = Host.CreateWebClient();
|
||||
string result = client.GetPage("WithoutResources.aspx");
|
||||
Assert.AreEqual("OK", result);
|
||||
}
|
||||
|
||||
@@ -26,6 +26,7 @@ using System.IO;
|
||||
using NUnit.Extensions.Asp.AspTester;
|
||||
using NUnit.Framework;
|
||||
using NUnitAspEx;
|
||||
using NUnitAspEx.Client;
|
||||
using Spring.TestSupport;
|
||||
|
||||
#endregion
|
||||
@@ -36,13 +37,17 @@ namespace Spring.Web.Support
|
||||
///
|
||||
/// </summary>
|
||||
/// <author>Erich Eichinger</author>
|
||||
[AspTestFixture("/Test", "/Spring/Web/Support/PageHandlerFactoryTests")]
|
||||
[TestFixture]
|
||||
public class PageHandlerFactoryTests : WebFormTestCase
|
||||
{
|
||||
public PageHandlerFactoryTests()
|
||||
: base("/Test", "/Spring/Web/Support/PageHandlerFactoryTests")
|
||||
{}
|
||||
|
||||
[Test]
|
||||
public void DisablesSessions()
|
||||
{
|
||||
AspTestClient client = new AspTestClient();
|
||||
HttpWebClient client = Host.CreateWebClient();
|
||||
// a session-less page - checks, if session is correctly disabled
|
||||
string result = client.GetPage("DisablesSession.aspx");
|
||||
Assert.AreEqual("OK", result);
|
||||
@@ -51,7 +56,7 @@ namespace Spring.Web.Support
|
||||
[Test, Explicit]
|
||||
public void UsesReadonlySession()
|
||||
{
|
||||
AspTestClient client = new AspTestClient();
|
||||
HttpWebClient client = Host.CreateWebClient();
|
||||
string result = client.GetPage("ReadOnlySession.aspx");
|
||||
Assert.AreEqual("OK", result);
|
||||
}
|
||||
@@ -59,18 +64,26 @@ namespace Spring.Web.Support
|
||||
[Test]
|
||||
public void MaintainsSession()
|
||||
{
|
||||
AspTestClient client = new AspTestClient();
|
||||
HttpWebClient client = Host.CreateWebClient();
|
||||
string result = client.GetPage("MaintainsSession1.aspx");
|
||||
Assert.AreEqual("OK", result);
|
||||
Assert.AreEqual("somevalue", AspTestContext.HttpContext.Session["maintainsSession"]);
|
||||
// Assert.AreEqual("somevalue", AspTestContext.HttpContext.Session["maintainsSession"]);
|
||||
|
||||
// checks previously set session variable
|
||||
result = client.GetPage("MaintainsSession2.aspx");
|
||||
Assert.AreEqual("OK", result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the behavior of the System.Web.PageHandlerFactory class
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void BCLPageHandlerFactoryBehavior()
|
||||
{
|
||||
Host.Execute(new TestAction(BCLPageHandlerFactoryBehaviorImpl));
|
||||
}
|
||||
|
||||
public static void BCLPageHandlerFactoryBehaviorImpl()
|
||||
{
|
||||
using (TestWebContext ctx = new TestWebContext("/Test", "DoesNotExist.oaspx"))
|
||||
{
|
||||
@@ -93,8 +106,16 @@ namespace Spring.Web.Support
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tests the behavior of our PageHandlerFactory class
|
||||
/// </summary>
|
||||
[Test]
|
||||
public void PageHandlerFactoryBehavesLikeSystemPageHandlerFactory()
|
||||
{
|
||||
Host.Execute(new TestAction(PageHandlerFactoryBehavesLikeSystemPageHandlerFactoryImpl));
|
||||
}
|
||||
|
||||
public static void PageHandlerFactoryBehavesLikeSystemPageHandlerFactoryImpl()
|
||||
{
|
||||
using (TestWebContext ctx = new TestWebContext("/Test", "DoesNotExist.aspx"))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user