Example #1
0
        public void EqualShouldWorkProperly(Expression <Func <AllTypesModel, IComparable> > selector)
        {
            this.navigator.AllTypesDataPage().GoTo();

            var colName         = this.GetColumnName(selector);
            var filterValue     = this.GetRandomValue(selector.Compile());
            var table           = new TableElement("table", this.driver);
            var filterContainer = new CustomFilterContainer(this.driver, "#custom-filters-container");

            filterContainer.Eq(colName, filterValue.ToString());
            var columnFilteredValues = table.GetColumnRowValues(colName);

            Assert.IsTrue(columnFilteredValues.All(x => x.ToLower() == filterValue.ToString().ToLower()));
        }
Example #2
0
        public void SingleRangeConditionShouldWorkProperly(Expression <Func <AllTypesModel, IComparable> > selector, Func <string, IComparable> parseFunc, RangeOperationTypesEnum operationType, Func <object, string> inputFormat = null)
        {
            this.navigator.AllTypesDataPage().GoTo();

            var colName         = this.GetColumnName(selector);
            var filterValue     = this.GetRandomValue(selector.Compile());
            var table           = new TableElement("table", this.driver);
            var filterContainer = new CustomFilterContainer(this.driver, "#custom-filters-container");

            inputFormat = inputFormat ?? new Func <object, string>(x => x.ToString());
            switch (operationType)
            {
            case RangeOperationTypesEnum.gt:
                filterContainer.Gt(colName, inputFormat(filterValue));
                break;

            case RangeOperationTypesEnum.gte:
                filterContainer.Gte(colName, inputFormat(filterValue));
                break;

            case RangeOperationTypesEnum.lt:
                filterContainer.Lt(colName, inputFormat(filterValue));
                break;

            case RangeOperationTypesEnum.lte:
                filterContainer.Lte(colName, inputFormat(filterValue));
                break;

            case RangeOperationTypesEnum.eq:
                filterContainer.Eq(colName, inputFormat(filterValue));
                break;

            default:
                break;
            }

            Thread.Sleep(GlobalConstants.GlobalThreadSleep);
            var columnFilteredValues = table.GetColumnRowValuesUntilAny(colName);
            var parsedValues         = columnFilteredValues.Select(parseFunc);

            Assert.IsNotEmpty(parsedValues);
            var filterparsedValue = parseFunc(filterValue.ToString());

            switch (operationType)
            {
            case RangeOperationTypesEnum.gt:
                Assert.IsTrue(parsedValues.All(x => x.CompareTo(filterparsedValue) > 0));
                break;

            case RangeOperationTypesEnum.gte:
                Assert.IsTrue(parsedValues.All(x => x.CompareTo(filterparsedValue) >= 0));
                break;

            case RangeOperationTypesEnum.lt:
                Assert.IsTrue(parsedValues.All(x => x.CompareTo(filterparsedValue) < 0));
                break;

            case RangeOperationTypesEnum.lte:
                Assert.IsTrue(parsedValues.All(x => x.CompareTo(filterparsedValue) <= 0));
                break;

            case RangeOperationTypesEnum.eq:
                Assert.IsTrue(parsedValues.All(x => x.CompareTo(filterparsedValue) == 0));
                break;

            default:
                break;
            }
        }