private static void Visibility(Tester tester, bool expectedVisibility) { string not = expectedVisibility ? " not" : ""; string message = String.Format("Unexpectedly{0} visible: {1}", not, tester.HtmlIdAndDescription); Visibility(tester, expectedVisibility, message); }
private static void Visibility(Tester tester, bool expectedVisibility, string message) { message = string.Format("{0}: {1}", message, tester.HtmlIdAndDescription); True(tester.Visible == expectedVisibility, message); }
/// <summary> /// Asserts that a specific control is on the current web page, with the "Visible" /// parameter set to "true." This method does not assert that the control is actually /// visible to the user. /// </summary> /// <param name="tester">The tester for the control to check.</param> public static void Visible(Tester tester) { Visibility(tester, true); }
/// <summary> /// Asserts that a specific control is on the current web page, with the "Visible" /// parameter set to "true." This method does not assert that the control is actually /// visible to the user. /// </summary> /// <param name="tester">The tester for the control to check.</param> /// <param name="message">The error message to display if the assertion fails.</param> public static void Visible(Tester tester, string message) { Visibility(tester, true, message); }
/// <summary> /// Asserts that a specific control is not on the current web page, or if it is, /// its "Visible" parameter is set to "false." This method does not distinguish /// between non-existant controls and non-visible controls: use with caution. /// </summary> /// <param name="tester">The tester for the control to check.</param> public static void NotVisible(Tester tester) { Visibility(tester, false); }
/// <summary> /// Asserts that a specific control is not on the current web page, with the "Visible" /// parameter set to "true." This method does not assert that the control is actually /// visible to the user. /// </summary> /// <param name="tester">The tester for the control to check.</param> /// <param name="message">The error message to display if the assertion fails.</param> public static void NotVisible(Tester tester, string message) { Visibility(tester, false, message); }
/// <summary> /// Create a tester that has no ID. This constructor is for NUnitAsp internal use /// and should be avoided. It will likely change in a future release. /// </summary> protected ControlTester(Tester container) : this(null, container) { }
/// <summary> /// Create a tester for a nested control. Use this constructor when /// the control you are testing is nested within another control, /// such as a DataGrid or UserControl. You should also use this /// constructor when you're not using the /// <see cref="HttpClient.Default"/> HttpClient. /// </summary> /// <param name="aspId">The ID of the control to test (look in the /// page's ASP.NET source code for the ID).</param> /// <param name="container">A tester for the control's container. /// (In the page's ASP.NET source code, look for the tag that the /// control is nested in. That's probably the control's /// container.)</param> /// /// <example> /// This example demonstrates how to test a label that's inside /// of a user control: /// /// <code> /// UserControlTester user1 = new UserControlTester("user1"); /// LabelTester label = new LabelTester("label", user1);</code> /// </example> /// /// <example>This example demonstrates how to use an HttpClient /// other than <see cref="HttpClient.Default"/>: /// /// <code> /// HttpClient myHttpClient = new HttpClient(); /// WebFormTester webForm = new WebFormTester(myHttpClient); /// LabelTester myTester = new LabelTester("id", webForm);</code> /// </example> public ControlTester(string aspId, Tester container) { this.aspId = aspId; this.container = container; }
/// <summary> /// Create a tester for a server-side HTML control or a tag that's on a /// page with multiple forms. Use this constructor when the HTML tag you /// are testing has the "runat='server'" attribute. /// Also use this tester when using the non-default webform or HttpClient. /// </summary> /// <param name="aspId">The ID of the control to test (look in the /// page's ASP.NET source code for the ID).</param> /// <param name="container">A tester for the control's container. /// (In the page's ASP.NET source code, look for the tag that the /// control is nested in. That's probably the control's /// container.) If testing a page with multiple forms or a non-default /// HttpClient, pass in the WebFormTester for the form this tag is within.</param> public HtmlTagTester(string aspId, Tester container) : base(aspId, container) { }
/// <summary> /// Create a tester for an HTML tag that's on a page with multiple forms using /// an XPath description. /// </summary> /// <param name="xpath">The XPath description of the tag.</param> /// <param name="description">A human-readable description of this tag (for error reporting).</param> /// <param name="container">A tester for the control's container. A WebFormTester /// will usually be most appropriate.</param> public HtmlTagTester(string xpath, string description, Tester container) : base(container) { this.xpath = xpath; this.description = description; }
/// <summary> /// Create the tester and link it to an ASP.NET control. /// </summary> /// <param name="aspId">The ID of the control to test (look in the page's ASP.NET source code for the ID).</param> /// <param name="container">A tester for the control's container. (In the page's ASP.NET /// source code, look for the tag that the control is nested in. That's probably the /// control's container. Use CurrentWebForm if the control is just nested in the form tag.)</param> public ControlTester(string aspId, Tester container) { this.AspId = aspId; this.container = container; }