Assertions specific to NUnitAsp's web testers.
Exemple #1
0
        /// <summary>
        /// Remove a specific name/value pair.  If the pair is in the collection more
        /// than once, this method will only remove one of them.
        /// </summary>
        public void Remove(string name, string value)
        {
            int i = IndexOf(name, value);

            WebAssert.True(i != -1, String.Format("Couldn't find form variable '{0}={1}' to remove in {2}", name, value, ToString()));

            variables.RemoveAt(i);
        }
Exemple #2
0
        /// <summary>
        /// Returns the value of a cookie.  Throws exception if the cookie hasn't been set.
        /// </summary>
        public string CookieValue(string cookieName)
        {
            if (!HasCookie(cookieName))
            {
                WebAssert.Fail("Expected cookie '" + cookieName + "' to be set");
            }
            CookieCollection cc = cookies.GetCookies(currentUrl);

            return(cc[cookieName].Value);
        }
Exemple #3
0
 /// <summary>
 /// For backwards compatibility; will be deprecated in the future.
 /// </summary>
 public static void AssertVisibility(ControlTester tester, bool expectedVisibility)
 {
     if (expectedVisibility)
     {
         WebAssert.Visible(tester);
     }
     else
     {
         WebAssert.NotVisible(tester);
     }
 }
Exemple #4
0
        internal FormVariables VariablesFor(string formHtmlId)
        {
            if (formVariables == null)
            {
                ParsePageText();
            }
            FormVariables result = (FormVariables)formVariables[formHtmlId];

            WebAssert.NotNull(result, "form ID '" + formHtmlId + "' not found on current page");
            return(result);
        }
Exemple #5
0
        private HtmlTagTester FindTagByForm()
        {
            XmlNodeList formNodes = browser.CurrentPage.Document.GetElementsByTagName("form");

            WebAssert.True(formNodes.Count == 1, "The current page has more than one form.  To test it, construct a WebFormTester and use it as the 'container' parameter for your other testers.");
            XmlElement formElement = (XmlElement)formNodes[0];

            XmlAttribute id = formElement.Attributes["id"];

            WebAssert.NotNull(id, "couldn't find web form's 'id' attribute");

            return(new HtmlTagTester(id.Value));
        }
Exemple #6
0
 /// <summary>
 /// For backwards compatibility; will be deprecated in the future.
 /// </summary>
 public static void AssertSortOrder(string message, string[][] data, int column, bool isAscending, DataType type)
 {
     WebAssert.Sorted(data, column, isAscending, type, message);
 }
Exemple #7
0
 /// <summary>
 /// For backwards compatibility; will be deprecated in the future.
 /// </summary>
 public static void AssertEqualsIgnoreOrder(string message, string[][] expected, string[][] actual)
 {
     WebAssert.AreEqualIgnoringOrder(expected, actual, message);
 }
Exemple #8
0
 /// <summary>
 /// For backwards compatibility; will be deprecated in the future.
 /// </summary>
 public static void AssertEquals(string message, string[][] expected, string[][] actual)
 {
     WebAssert.AreEqual(expected, actual, message);
 }
Exemple #9
0
 /// <summary>
 /// Submit this form to the server.
 /// </summary>
 public void Submit()
 {
     WebAssert.Visible(this);
     browser.SubmitForm(this);
 }
Exemple #10
0
 /// <summary>
 /// Returns the value of the name/value pair with the specified name.
 /// Throws an exception if there aren't any pairs with that name or
 /// if there's more than one.  Use <see cref="AllValuesOf"/> to handle
 /// cases where there isn't exactly one name/value pair with the
 /// requested name.
 /// </summary>
 public string ValueOf(string name)
 {
     string[] result = AllValuesOf(name);
     WebAssert.AreEqual(1, result.Length, "number of '" + name + "' variables");
     return(result[0]);
 }
Exemple #11
0
 /// <summary>
 /// Experimental.  May change or go away in future revisions.  Allows testers to
 /// assert that their control should be visible before some operations.  Using
 /// this method provides clearer error messages to users of the tester.
 /// </summary>
 protected void AssertVisible()
 {
     WebAssert.Visible(this);
 }
Exemple #12
0
 /// <summary>
 /// Returns the only child (of a particular type) of this tag.  If this tag has more
 /// that one child of the requested type, or if it has no children of the requested type,
 /// this method will throw an exception.  Don't cache the results of this call.
 /// </summary>
 /// <param name="tag">The type of tag to look for.  Don't include angle brackets.</param>
 public HtmlTagTester Child(string tag)
 {
     HtmlTagTester[] tags = Children(tag);
     WebAssert.True(tags.Length == 1, "Expected " + Description + " to have exactly one <" + tag + "> child tag.");
     return(tags[0]);
 }