csharpfritz / WebFormsTest

A unit test harness to assist in testing .NET code in an ASP.NET web forms project
Apache License 2.0
24 stars 13 forks source link

Can't find Controls - WebForms w/ nested Master pages #58

Open 2chivi opened 1 day ago

2chivi commented 1 day ago

Has anyone had any success using WebFormsTest with nested Master Pages in WebForms?

I'm able to get WebApplicationProxy.Create to run, and WebApplicationProxy.GetPageLocation to run just fine, but controls are never able to be found.


WebApplicationProxy.Create(typeof(Platform.applications.applications), options);
var page= WebApplicationProxy.GetPageByLocation<Platform.applications.test>("/applications/test.aspx");
page.RunToEvent(WebFormEvent.Init);

var testControl= page.FindControl("btnTest");  // no controls are ever found recursively or otherwise.

Here is an example Master-page that inherits from a nested Master Page

<%@ Master Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true" CodeBehind="Site1.master.cs" Inherits="Platform.applications.Site1" %>
<%@ MasterType VirtualPath="~/Main.Master" %>

<asp:Content ID="Content2" ContentPlaceHolderID="m" runat="server">
    <asp:ContentPlaceHolder ID="m" runat="server">
    </asp:ContentPlaceHolder>
</asp:Content>`

Thanks

2chivi commented 1 day ago

Confirmed that AddMasterPage() in InternalPageExtensions.cs is not correctly handling nested Master pages.