Andrew Skiba ebd68f4948 run NunitWeb on GH 2.0 пре 19 година
..
Resources ebd68f4948 run NunitWeb on GH 2.0 пре 19 година
BaseControl.cs 737ae5d65e Ability to run tests on real web server; documentation corrections. пре 19 година
BaseControlCollection.cs 737ae5d65e Ability to run tests on real web server; documentation corrections. пре 19 година
BaseInvoker.cs 737ae5d65e Ability to run tests on real web server; documentation corrections. пре 19 година
BaseRequest.cs 737ae5d65e Ability to run tests on real web server; documentation corrections. пре 19 година
BaseWorkerRequest.cs 992b155ab8 replace <seealso> tags to <see> to work around NDoc bug. пре 19 година
FAQ 101d846c4c add TODO and FAQ пре 19 година
FakeMembershipProvider.cs 4abc469313 * fixed DateTime.FromBinary to DateTime.Now пре 19 година
FormRequest.cs cf713fa961 return code that was commented out пре 19 година
HandlerInvoker.cs 992b155ab8 replace <seealso> tags to <see> to work around NDoc bug. пре 19 година
IForeignData.cs 3b0ec97744 Inline documentation is complete. This commit includes also some minor interface changes. пре 19 година
MyHandler.cs ccb0c91e4f copy resources before creating domain so web.config is seen by the runtime; serialize WebTest between domains instead of copying field in MyData; add UserData property for custom data transfer in tests пре 19 година
MyHost.cs 3ccd99c67a SendHeaders stub method пре 19 година
MyHost.jvm.cs ebd68f4948 run NunitWeb on GH 2.0 пре 19 година
NunitWeb-default.csproj a861f3b841 Add projects for generating the documentation with NDoc пре 19 година
NunitWeb-default.sln a861f3b841 Add projects for generating the documentation with NDoc пре 19 година
NunitWeb.csproj e6d798c7f9 add ref to Soap formatter пре 19 година
NunitWeb.vmwcsproj ebd68f4948 run NunitWeb on GH 2.0 пре 19 година
NunitWeb20.vmwcsproj 485289b578 add projects and batch files for GH 2.0 tests пре 19 година
PageDelegates.cs 992b155ab8 replace <seealso> tags to <see> to work around NDoc bug. пре 19 година
PageInvoker.cs 992b155ab8 replace <seealso> tags to <see> to work around NDoc bug. пре 19 година
PostableRequest.cs 737ae5d65e Ability to run tests on real web server; documentation corrections. пре 19 година
PostableWorkerRequest.cs 3b0ec97744 Inline documentation is complete. This commit includes also some minor interface changes. пре 19 година
README 5ef0eab7f7 readme update пре 19 година
Response.cs 992b155ab8 replace <seealso> tags to <see> to work around NDoc bug. пре 19 година
StandardUrl.cs 992b155ab8 replace <seealso> tags to <see> to work around NDoc bug. пре 19 година
TODO e9ee3eda80 пре 19 година
WebTest.cs 65b12aac97 ObjectDataSourceViewTest.cs: added new tests пре 19 година
nunitweb.ndoc 737ae5d65e Ability to run tests on real web server; documentation corrections. пре 19 година

README

The idea of the framework is as the following. A web application root is created
in a temp directory. All currently referenced and loaded assemblies are copied
to the /bin folder. Starting from this point, HttpRuntime.ProcessRequest() is
able to process any requests, compiling aspx, themes, master pages, etc. if
necessary.

Few words about the API.

WebTest is the central class of the framework. It's instances are typically
created in Nunit testcases. WebTest instances carry the information from the
testcase appdomain into the web application appdomain, and back. The most
important properties of WebTest are Request and Invoker. The request carries all
the information, necessary to create an HttpWorkerRequest in the web appdomain.
The invoker carries all the callbacks which have to be invoked to perform the
tests in the web appdomain. Here is an example of using the WebTest, Request,
and Invoker.

[Test]
public void TestCase1 ()
{
WebTest t = new WebTest ();
t.Invoker = PageInvoker.CreateOnLoad (TestCase1OnLoad));
t.Request.Url = "MyPage.aspx";
string htmlRes = t.Run();
//HtmlDiff on htmlRes ...
}

static public void TestCase1OnLoad (Page p) //invoked in the web appdomain
{
Assert.AreEqual ("White", p.StyleSheetTheme);
}

There is a support for postback. The flow goes like this: you make a first
request like:

WebTest t = new WebTest ("SomePage.aspx");
t.Run ();

Then you use the response to create a FormRequest:

FormRequest f = new FormRequest (t.Response);

This will parse the response, and use action URL, GET/POST method and all
hidden fields (VIEWSTATE, etc.) You might add more query parameters, like

f.Controls.Add (new BaseControl ("button1", ""));
f.Controls.Add (new BaseControl ("textbox1", "some text");

and run the second request:

t.Request = f;
t.Run ();

It can be useful to install some callbacks for the second request, before
calling to t.Run(), like the following:

t.Invoker = PageInvoker.CreateOnLoad (MyDelegate);

the delegate for the above test might look like:

t.Invoker = PageInvoker.CreateOnLoad (MyDelegate);

static public void MyDelegate (Page p)
{
Assert.IsTrue (p.IsPostBack);
Assert.AreEqual ("some text", ((TextControl)p.FindControl ("textbox1")).Text);
}