1: [TestMethod, Isolated]
2: public void LoadWebPage_SpSimpleWebPart_3EntriesInList()
3: {
4: // Arrange
5: TestHelpers.CreateFakeSPSite();
6: TestHelpers.CreateFakeURL();
7:
8: TestSession session = new TestSession(); //Start each test with this
9: WebRequest request = new WebRequest("/SpSimpleTest.aspx"); //Create a WebRequest object
10:
11: // Act
12: WebResponse response = session.ProcessRequest(request); //Process the request
13:
14: // Assert
15: //Check the page loaded
16: Assert.IsNotNull(response.Page);
17:
18: // the the Ivonna extension method to find the control
19: var wp = response.Page.FindRecursive<DemoWebParts.SpSimpleWebPart>("wp1");
20: Assert.IsNotNull(wp);
21:
22: // so we have to use the following structure and dig knowing the format
23: // webpart/table/row/cell/control
24: var label = ((TableRow)wp.Controls[0].Controls[0]).Cells[1].Controls[0] as Label;
25: Assert.IsNotNull(label);
26: Assert.AreEqual("http://mockedsite.com",label.Text);
27:
28: var list = ((TableRow)wp.Controls[0].Controls[1]).Cells[1].Controls[0] as DropDownList;
29: Assert.IsNotNull(list);
30: Assert.AreEqual(3, list.Items.Count);
31: }