Skip to content

Features Supported

Jeffrey T. Fritz edited this page Feb 10, 2016 · 6 revisions

The `WebApplicationProxy provides a number of ways that you can interact with your web application to be able to verify functionality. Think of this object as the server that is hosting your application and it provides a port-hole, a gateway into the inner workings of the application so that you can inspect how it is functioning.

About the WebFormsTest library

The WebApplicationProxy is your "web server" for your application. It will inspect and host your application in a separate appdomain and provide access to the pages, controls, and the content of your application without needing to start another process or launch a browser. Everything is accessible programmatically. This also means that you can test your application with the same framework constructs that you would expect to be available while the application is normally running. There is no need for a HttpContextBase or an HttpRequestBase, you can use the direct HttpContext and HttpRequest objects that your application uses. The WebFormsTest library has several extension methods for these objects that will assist in configuring them to meet your testing needs.

Fire page events

Web Forms code is typically written as modifications or additions to the four standard Page events: Init, Load, PreRender and Unload. You can trigger these events and pass in your own collection of event arguments with the Page.FireEvent extension method.

Inspect Rendered HTML

At any time you can call the RenderHTML extension method to return the HTML that the page would create. This method executes the Render method that the Page would normally execute when delivering content to the requesting client.

Detect if testing is enabled

A boolean true value is added to the HttpContext.Items["IsInTestMode"] item. You can inspect this value to determine if an application is running in 'Test' mode

Precompile the Web Application on the fly

The WebApplicationProxy object will precompile parts of your web application as you request them so that you may inspect the controls and masterpages that are effected by the code written into ASPX / ASCX / Masterpage files.

AutoEvents

When you use the WebApplicationProxy to precompile and work with your application, pages and controls that are marked with AutoEventWireup="true" will have their event handlers automatically connected to the code-behind.

Page Event Lifecycle

Use the Page.RunToEvent extension method to execute all of the events on a WebForm leading up to the event that you want to stop at. Then you can perform your tests with the page in the state that you desire.

Set Page Control State Easily

Configure your pages that you want to test using the fluid API in the Page.SetPageState extension method. This will allow you to quickly set properties and call methods on any control on your page.