Beispiel #1
0
        private static void AssertTextPropertyOrder(string columnName, SortDirectionsEnum direction, TableElement tableElement)
        {
            var actualColumnValues = tableElement.GetColumnRowValues(columnName);

            var expectedColumnValues = direction == SortDirectionsEnum.Asc ?
                                       actualColumnValues.OrderBy(x => x) :
                                       actualColumnValues.OrderByDescending(x => x);

            Assert.IsNotEmpty(actualColumnValues);
            Assert.IsTrue(expectedColumnValues.SequenceEqual(actualColumnValues));
        }
Beispiel #2
0
        public void Sort_SholdWorkAppropriateForNonTextTypes(string columnName, SortDirectionsEnum direction, Type propertyType)
        {
            ExceptionsHandler.Hande(() =>
            {
                this.navigator.AllTypesDataPage().GoTo();
                var tableElement    = new TableElement("table", this.driver);
                string columnHeader = columnName.StartsWith("NestedModel") ? this.GetHeaderForNestedModel(columnName) : columnName;
                tableElement.ClickSortButton(columnHeader, direction);

                AssertNonTextPropertyOrder(columnName, columnHeader, direction, propertyType, tableElement);
                tableElement.GoToLastPage();
                AssertNonTextPropertyOrder(columnName, columnHeader, direction, propertyType, tableElement);
            },
                                    this.driver);
        }
Beispiel #3
0
        public void Sort_SholdWorkAppropriateForTextTypes(string columnName, SortDirectionsEnum direction)
        {
            ExceptionsHandler.Hande(() =>
            {
                this.navigator.AllTypesDataPage().GoTo();
                var tableElement = new TableElement("table", this.driver);
                tableElement.ClickSortButton(columnName, direction);

                // Assert that rows are in correct order for the first page
                AssertTextPropertyOrder(columnName, direction, tableElement);
                tableElement.GoToLastPage();
                // Assert that rows are in correct order for the last page
                AssertTextPropertyOrder(columnName, direction, tableElement);
            },
                                    this.driver);
        }
        /// <summary>
        /// Clicks the sort button. If no <paramref name="isAsc"/> value is provided the buton will be clicked single time.
        /// Otherwise the button will be clicked until the order direction is set to asc or desc.
        /// </summary>
        /// <param name="column">The column.</param>
        /// <param name="isAsc">The is asc.</param>
        public void ClickSortButton(string column, SortDirectionsEnum direction = SortDirectionsEnum.Default)
        {
            string classToHave = direction == SortDirectionsEnum.Default ?
                                 "" :
                                 (direction == SortDirectionsEnum.Asc ?
                                  "sorting_asc" :
                                  "sorting_desc");

            IWebElement th;

            do
            {
                var thElements = this.table.FindElementsByCssSelector("thead th");
                th = thElements.Where(x => x.Text.ToLower() == column.ToLower()).Single();

                th.Click();
                Thread.Sleep(1000);
            } while (direction != SortDirectionsEnum.Default && !th.GetAttribute("class").Contains(classToHave));
        }
Beispiel #5
0
        private void AssertNonTextPropertyOrder(string columnName, string columnHeader, SortDirectionsEnum direction, Type propertyType, TableElement tableElement)
        {
            var actualColumnValues = tableElement.GetColumnRowValues(columnHeader);

            var stringParseFunction  = this.GetStringParseFunction(columnName, propertyType);
            var expectedColumnValues = direction == SortDirectionsEnum.Asc ?
                                       actualColumnValues.OrderBy(stringParseFunction) :
                                       actualColumnValues.OrderByDescending(stringParseFunction);

            Assert.IsNotEmpty(actualColumnValues);
            Assert.IsTrue(expectedColumnValues.SequenceEqual(actualColumnValues));
        }