Tester for System.Web.UI.WebControls.DataGrid
Inheritance: AspControlTester
Ejemplo n.º 1
0
 protected override void SetUp()
 {
     base.SetUp();
     button = new HtmlButtonTester("button");
     formVars = new DataGridTester("formVars", CurrentWebForm);
     Browser.GetPage(BaseUrl + "HtmlTester/HtmlButtonTestPage.aspx");
 }
Ejemplo n.º 2
0
 private static string GetMessage(string aspId, DataGridTester dataGrid)
 {
     return(String.Format(
                "Tester '{0}' has DataGridTester '{1}' as its container. That isn't allowed. "
                + "It should be a DataGridTester.Row. When constructing {0}, pass '{1}.getRow(#)' "
                + "as the container argument.",
                aspId, dataGrid.AspId));
 }
Ejemplo n.º 3
0
 private static string GetMessage(string aspId, DataGridTester dataGrid)
 {
     return String.Format(
         "Tester '{0}' has DataGridTester '{1}' as its container. That isn't allowed. "
         + "It should be a DataGridTester.Row. When constructing {0}, pass '{1}.getRow(#)' "
         + "as the container argument.",
         aspId, dataGrid.AspId);
 }
Ejemplo n.º 4
0
        public void CreateAccount()
        {
            // use the ViewAccounts page to create a new account.
            // This shows how to interact with the asp form, but also
            // that testing the ASPX page doesn't have as much value
            // as you might think.

            #region some constants
            const string newName = "Testing Account";
            const string newBalance = "1234";
            #endregion

            #region set up the page

            LoadPage("viewaccounts.aspx");

            TextBoxTester txtName = new TextBoxTester("txtName",
                                                        CurrentWebForm);
            TextBoxTester txtBalance = new TextBoxTester("txtBalance",
                                                        CurrentWebForm);
            ButtonTester btnCreate = new ButtonTester("btnCreate",
                                                        CurrentWebForm);
            #endregion

            #region fill in some data & submit form

            txtName.Text = newName;
            txtBalance.Text = newBalance;

            btnCreate.Click();

            #endregion

            #region Datagrid - did it work?

            // the page has refreshed --
            // see if our new account is in the grid.
            DataGridTester grdAccounts = new DataGridTester(
                                                    "grdAccounts",
                                                    CurrentWebForm);
            // the last row is the newest one:
            DataGridTester.Row newRow = grdAccounts.GetRow(grdAccounts.RowCount - 1);
            // first cell is account id, 2nd is account name
            // name should be the same as the value we just saved...
            Assert("New account wasn't last in the grid",
                newRow.TrimmedCells[1] == newName);

            #endregion

            #region teardown
            // delete the account we just created.
            AccountFactory.DeleteAccount(int.Parse(newRow.TrimmedCells[0]));
            #endregion
        }
Ejemplo n.º 5
0
 internal ContainerMustBeRowException(string aspId, DataGridTester dataGrid)
     : base(GetMessage(aspId, dataGrid))
 {
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Create the tester and link it to a row in a specific data grid.
 /// </summary>
 /// <param name="rowNumberWhereZeroIsHeader">The row to test.</param>
 /// <param name="container">The data grid that contains the row.</param>
 public Row(int rowNumberWhereZeroIsHeader, DataGridTester container) : base(rowNumberWhereZeroIsHeader.ToString(), container)
 {
     this.rowNumber = rowNumberWhereZeroIsHeader;
     this.container = container;
 }
Ejemplo n.º 7
0
        protected override void SetUp()
        {
            button1A = new HtmlInputRadioButtonTester("button1A");
            button1B = new HtmlInputRadioButtonTester("button1B");
            postback = new LinkButtonTester("postback");
            formVars = new DataGridTester("formVars", CurrentWebForm);

            Browser.GetPage(BaseUrl + "HtmlTester/HtmlInputRadioButtonTestPage.aspx");
        }
Ejemplo n.º 8
0
 protected override void SetUp()
 {
     base.SetUp();
     image = new HtmlInputImageTester("image");
     formVars = new DataGridTester("formVars", CurrentWebForm);
     Browser.GetPage(BaseUrl + "HtmlTester/HtmlInputImageTestPage.aspx");
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Looks for the given list name in Dynamic List Admin page.
        /// </summary>
        /// <param name="listName">Name of List</param>
        /// <returns></returns>
        private bool testDynamicListAdmin(string listName)
        {
            Console.WriteLine("testDynamicListAdmin");
            //DnaTestURLRequest dnarequest = new DnaTestURLRequest("haveyoursay");
            _dnarequest.SetCurrentUserEditor();
            _dnarequest.UseEditorAuthentication = true;
            string relativePath = @"/dna/haveyoursay/DynamicListAdmin";
            _dnarequest.RequestNUnitASPPage(relativePath, Browser);

            DataGridTester table = new DataGridTester("tblDynamicLists", CurrentWebForm);
            bool found = false;
            for (int i = 0; i < table.RowCount; ++i)
            {
                DataGridTester.Row row = table.GetRow(i);
                string[] cells = row.TrimmedCells;
                if (cells[0] == listName)
                {
                    //List Created OK 
                    found = true;
                    break;
                }
            }

            Assert.IsTrue(found, "DynamicList has not been created and displayed in DynamicListAdmin.");
            return found;
        }
Ejemplo n.º 10
0
 internal ContainerMustBeRowException(string aspId, DataGridTester dataGrid)
     : base(GetMessage(aspId, dataGrid))
 {
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Create the tester and link it to a row in a specific data grid.
 /// </summary>
 /// <param name="rowNumberWhereZeroIsHeader">The row to test.</param>
 /// <param name="container">The data grid that contains the row.</param>
 public Row(int rowNumberWhereZeroIsHeader, DataGridTester container)
     : base(rowNumberWhereZeroIsHeader.ToString(), container)
 {
     this.rowNumber = rowNumberWhereZeroIsHeader;
     this.container = container;
 }
Ejemplo n.º 12
0
        protected override void SetUp()
        {
            base.SetUp();
            grid1 = new DataGridTester("dataGrid1", CurrentWebForm);
            grid2 = new DataGridTester("dataGrid2", CurrentWebForm);
            clickResult = new LabelTester("clickResult", CurrentWebForm);
            headerResult = new LabelTester("headerResult", CurrentWebForm);

            Browser.GetPage(BaseUrl + "AspTester/DataGridTestPage.aspx");
        }