upgraded to NUnitAspEx 2.0.3482.27831 - no nunit dependency anymore

This commit is contained in:
eeichinger
2009-07-14 16:59:47 +00:00
parent ee682866bf
commit ec75e5c13a
12 changed files with 417 additions and 69 deletions

Binary file not shown.

139
lib/Net/1.1/NUnitAspEx.xml Normal file
View File

@@ -0,0 +1,139 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>NUnitAspEx</name>
</assembly>
<members>
<member name="T:NUnitAspEx.Client.AspFixtureRequest">
<summary>
Encapsulates a request from within a testsuite using the "asptest://" pseudo-protocol.
</summary>
</member>
<member name="T:NUnitAspEx.Client.CustomizableHttpWebRequest">
<summary>
Encapsulates the ugly details of deriving from HttpWebRequest.
</summary>
<remarks>
Since various frameworks like NUnitAsp rely on the output of WebRequest.Create() being of type HttpWebRequest
but HttpWebRequest is not customizable the easy way, this class shields further derived classes from the ugly reflection details.
</remarks>
</member>
<member name="M:NUnitAspEx.Client.CustomizableHttpWebRequest.#ctor(System.Uri)">
<summary>
Creates a new instance for the given uri.
</summary>
<param name="uri">the <see cref="P:NUnitAspEx.Client.CustomizableHttpWebRequest.Uri"/> to create this request for.</param>
</member>
<member name="M:NUnitAspEx.Client.CustomizableHttpWebRequest.CreateHttpWebRequestSerializationInfo(System.Uri)">
<summary>
</summary>
<param name="uri"></param>
<returns></returns>
</member>
<member name="M:NUnitAspEx.Client.CustomizableHttpWebRequest.SubmitRequest(System.Byte[],System.IO.Stream)">
<summary>
Override this method in your derived class and call <see cref="M:NUnitAspEx.Client.CustomizableHttpWebRequest.SetResponse(System.Net.HttpWebResponse)"/> to set the response object.
</summary>
</member>
<member name="M:NUnitAspEx.Client.CustomizableHttpWebRequest.CreateOutputStream">
<summary>
Create the stream to be used for uploading content.
</summary>
<returns></returns>
</member>
<member name="T:NUnitAspEx.Client.AspFixtureResponse">
<summary>
Encapsulates a response from an <see cref="T:NUnitAspEx.Client.AspFixtureRequest"/>.
</summary>
</member>
<member name="T:NUnitAspEx.Client.CustomizableHttpWebResponse">
<summary>
Encapsulates the ugly details of deriving from HttpWebResponse.
</summary>
</member>
<member name="T:NUnitAspEx.Client.HttpReflectionUtils">
<summary>
Summary description for HttpReflectionUtils.
</summary>
</member>
<member name="T:NUnitAspEx.Client.HttpWebClient">
<summary>
Summary description for HttpWebClient.
</summary>
</member>
<member name="T:NUnitAspEx.Core.AspFixtureHost">
<summary>
An AspFixtureHost lives inside it's own AppDomain with an initialized HttpRuntime.
</summary>
</member>
<member name="T:NUnitAspEx.IAspFixtureHost">
<summary>
Summary description for IAspFixtureHost.
</summary>
</member>
<member name="M:NUnitAspEx.Core.AspFixtureHost.CreateInstance(System.String,System.String,System.String)">
<summary>
Creates a new Host instance within a new AppDomain based on the passed in Properties.
</summary>
<remarks>
You must not call this method from within an existing Host's AppDomain.
</remarks>
</member>
<member name="M:NUnitAspEx.Core.AspFixtureHost.ShutDown(NUnitAspEx.Core.AspFixtureHost)">
<summary>
Unload the passed Host's AppDomain.
</summary>
</member>
<member name="M:NUnitAspEx.Core.AspFixtureHost.InitializeLifetimeService">
<summary>
Return null to avoid timing out of remoting references
</summary>
<returns></returns>
</member>
<member name="M:NUnitAspEx.Core.AspFixtureHost.Initialize(System.String,System.AppDomain,System.IO.TextWriter,System.String[])">
<summary>
Initializes the newly created host instance.
</summary>
</member>
<member name="P:NUnitAspEx.Core.AspFixtureHost.Current">
<summary>
Use this property to gain access to the Host from within the Host's AppDomain
</summary>
<remarks>
This property is set only within the Host's AppDomain.
Outside the AppDomain it will always return null.
</remarks>
</member>
<member name="P:NUnitAspEx.Core.AspFixtureHost.SyncRoot">
<summary>
Use to synchronize access to this host instance
</summary>
</member>
<member name="P:NUnitAspEx.Core.AspFixtureHost.CreatorDomain">
<summary>
Returns a reference to the AppDomain, that created this Host instance
</summary>
</member>
<member name="P:NUnitAspEx.Core.AspFixtureHost.RootLocation">
<summary>
Returns the physical assembly reference location this AppDomain has been created from.
</summary>
</member>
<member name="T:NUnitAspEx.AspTestClient">
<summary>
Summary description for AspTestClient.
</summary>
</member>
<member name="T:NUnitAspEx.AspTestContext">
<summary>
Summary description for AspTestContext.
</summary>
</member>
<member name="T:NUnitAspEx.AspTestExecutionModule">
<summary>
Summary description for AspTestExecutionModule.
</summary>
</member>
</members>
</doc>

Binary file not shown.

139
lib/Net/2.0/NUnitAspEx.xml Normal file
View File

@@ -0,0 +1,139 @@
<?xml version="1.0"?>
<doc>
<assembly>
<name>NUnitAspEx</name>
</assembly>
<members>
<member name="T:NUnitAspEx.Client.AspFixtureRequest">
<summary>
Encapsulates a request from within a testsuite using the "asptest://" pseudo-protocol.
</summary>
</member>
<member name="T:NUnitAspEx.Client.CustomizableHttpWebRequest">
<summary>
Encapsulates the ugly details of deriving from HttpWebRequest.
</summary>
<remarks>
Since various frameworks like NUnitAsp rely on the output of WebRequest.Create() being of type HttpWebRequest
but HttpWebRequest is not customizable the easy way, this class shields further derived classes from the ugly reflection details.
</remarks>
</member>
<member name="M:NUnitAspEx.Client.CustomizableHttpWebRequest.#ctor(System.Uri)">
<summary>
Creates a new instance for the given uri.
</summary>
<param name="uri">the <see cref="P:NUnitAspEx.Client.CustomizableHttpWebRequest.Uri"/> to create this request for.</param>
</member>
<member name="M:NUnitAspEx.Client.CustomizableHttpWebRequest.CreateHttpWebRequestSerializationInfo(System.Uri)">
<summary>
</summary>
<param name="uri"></param>
<returns></returns>
</member>
<member name="M:NUnitAspEx.Client.CustomizableHttpWebRequest.SubmitRequest(System.Byte[],System.IO.Stream)">
<summary>
Override this method in your derived class and call <see cref="M:NUnitAspEx.Client.CustomizableHttpWebRequest.SetResponse(System.Net.HttpWebResponse)"/> to set the response object.
</summary>
</member>
<member name="M:NUnitAspEx.Client.CustomizableHttpWebRequest.CreateOutputStream">
<summary>
Create the stream to be used for uploading content.
</summary>
<returns></returns>
</member>
<member name="T:NUnitAspEx.Client.AspFixtureResponse">
<summary>
Encapsulates a response from an <see cref="T:NUnitAspEx.Client.AspFixtureRequest"/>.
</summary>
</member>
<member name="T:NUnitAspEx.Client.CustomizableHttpWebResponse">
<summary>
Encapsulates the ugly details of deriving from HttpWebResponse.
</summary>
</member>
<member name="T:NUnitAspEx.Client.HttpReflectionUtils">
<summary>
Summary description for HttpReflectionUtils.
</summary>
</member>
<member name="T:NUnitAspEx.Client.HttpWebClient">
<summary>
Summary description for HttpWebClient.
</summary>
</member>
<member name="T:NUnitAspEx.Core.AspFixtureHost">
<summary>
An AspFixtureHost lives inside it's own AppDomain with an initialized HttpRuntime.
</summary>
</member>
<member name="T:NUnitAspEx.IAspFixtureHost">
<summary>
Summary description for IAspFixtureHost.
</summary>
</member>
<member name="M:NUnitAspEx.Core.AspFixtureHost.CreateInstance(System.String,System.String,System.String)">
<summary>
Creates a new Host instance within a new AppDomain based on the passed in Properties.
</summary>
<remarks>
You must not call this method from within an existing Host's AppDomain.
</remarks>
</member>
<member name="M:NUnitAspEx.Core.AspFixtureHost.ShutDown(NUnitAspEx.Core.AspFixtureHost)">
<summary>
Unload the passed Host's AppDomain.
</summary>
</member>
<member name="M:NUnitAspEx.Core.AspFixtureHost.InitializeLifetimeService">
<summary>
Return null to avoid timing out of remoting references
</summary>
<returns></returns>
</member>
<member name="M:NUnitAspEx.Core.AspFixtureHost.Initialize(System.String,System.AppDomain,System.IO.TextWriter,System.String[])">
<summary>
Initializes the newly created host instance.
</summary>
</member>
<member name="P:NUnitAspEx.Core.AspFixtureHost.Current">
<summary>
Use this property to gain access to the Host from within the Host's AppDomain
</summary>
<remarks>
This property is set only within the Host's AppDomain.
Outside the AppDomain it will always return null.
</remarks>
</member>
<member name="P:NUnitAspEx.Core.AspFixtureHost.SyncRoot">
<summary>
Use to synchronize access to this host instance
</summary>
</member>
<member name="P:NUnitAspEx.Core.AspFixtureHost.CreatorDomain">
<summary>
Returns a reference to the AppDomain, that created this Host instance
</summary>
</member>
<member name="P:NUnitAspEx.Core.AspFixtureHost.RootLocation">
<summary>
Returns the physical assembly reference location this AppDomain has been created from.
</summary>
</member>
<member name="T:NUnitAspEx.AspTestClient">
<summary>
Summary description for AspTestClient.
</summary>
</member>
<member name="T:NUnitAspEx.AspTestContext">
<summary>
Summary description for AspTestContext.
</summary>
</member>
<member name="T:NUnitAspEx.AspTestExecutionModule">
<summary>
Summary description for AspTestExecutionModule.
</summary>
</member>
</members>
</doc>

View File

@@ -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();

View File

@@ -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
{
}
}

View File

@@ -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"))
{

View File

@@ -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" />

View File

@@ -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.");
}
}
}

View File

@@ -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);
}
}
}

View File

@@ -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);
}

View File

@@ -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"))
{