1 using NUnit
.Extensions
.Asp
;
2 using NUnit
.Extensions
.Asp
.AspTester
;
5 namespace Castle
.MVC
.Test
8 /// (If you receive a 401 Access Denied error, check your security settings.
9 /// For example, try enabling anonymous access for the GuestBook virtual directory,
10 /// and make sure the IUSR_machinename user has read access to the directory.)
13 public class WebFormTest
: WebFormTestCase
17 public void TestGoToPage2WithButtonLogin()
19 // First, instantiate "Tester" objects:
20 ButtonTester buttonLogin
= new ButtonTester("ButtonLogin", CurrentWebForm
);
21 LabelTester labelTester
= new LabelTester("LabelPreviousView", CurrentWebForm
);
23 // Second, visit the page being tested:
24 Browser
.GetPage("http://localhost/Castle.MVC.Test.Web/Views/index.aspx");
25 string loginPage
= this.Browser
.CurrentUrl
.AbsoluteUri
.ToString();
28 string currentPage
= this.Browser
.CurrentUrl
.AbsoluteUri
.ToString();
29 Assert(currentPage
, loginPage
!= currentPage
);
30 AssertEquals("index", labelTester
.Text
);
34 public void TestGoToPage2ViaLinkButton()
36 // First, instantiate "Tester" objects:
37 ButtonTester buttonLogin
= new ButtonTester("ButtonLogin", CurrentWebForm
);
38 LinkButtonTester link
= new LinkButtonTester("LinkToPage2", CurrentWebForm
);
39 LabelTester labelTester
= new LabelTester("LabelPreviousView", CurrentWebForm
);
41 // Second, visit the page being tested:
42 Browser
.GetPage("http://localhost/Castle.MVC.Test.Web/Views/index.aspx");
43 string loginPage
= this.Browser
.CurrentUrl
.AbsoluteUri
.ToString();
46 string currentPage
= this.Browser
.CurrentUrl
.AbsoluteUri
.ToString();
47 Assert(currentPage
, loginPage
!= currentPage
);
48 AssertEquals("index", labelTester
.Text
);
52 public void TestGoToPage2ViaButtoninUserControl()
54 // First, instantiate "Tester" objects:
55 UserControlTester myUserControl
= new UserControlTester("MyUserControl", CurrentWebForm
);
56 ButtonTester buttonGoToPage2
= new ButtonTester("GoToPage2", myUserControl
);
57 LabelTester labelTester
= new LabelTester("LabelPreviousView", CurrentWebForm
);
59 // Second, visit the page being tested:
60 Browser
.GetPage("http://localhost/Castle.MVC.Test.Web/Views/index.aspx");
61 string loginPage
= this.Browser
.CurrentUrl
.AbsoluteUri
.ToString();
63 buttonGoToPage2
.Click();
64 string currentPage
= this.Browser
.CurrentUrl
.AbsoluteUri
.ToString();
65 Assert(currentPage
, loginPage
!= currentPage
);
66 AssertEquals("index", labelTester
.Text
);
70 public void TestGoToPageIndex()
72 // First, instantiate "Tester" objects:
73 ButtonTester buttonLogin
= new ButtonTester("ButtonLogin", CurrentWebForm
);
74 ButtonTester button
= new ButtonTester("Button", CurrentWebForm
);
76 Browser
.GetPage("http://localhost/Castle.MVC.Test.Web/Views/index.aspx");
77 string loginPage
= this.Browser
.CurrentUrl
.AbsoluteUri
.ToString();
80 string currentPage
= this.Browser
.CurrentUrl
.AbsoluteUri
.ToString();
81 Assert(currentPage
, loginPage
.ToLower() == currentPage
.ToLower());