Exemplo n.º 1
0
        internal ByArgument(Identifier arg)
            : base(arg)
        {
            CtorBody(arg);
            SetArgType(arg);

            if (chainException == null)
            {
                // identifier should consist of alias and column.
                if (arg.NumberOfParts != 2)
                {
                    chainException = new QueryTalkException(this,
                                                            QueryTalkExceptionType.InvalidByIdentifier,
                                                            String.Format("identifier = {0}", arg),
                                                            Text.Method.Identifier);
                    return;
                }

                _alias  = arg.Part1;
                _column = arg.Part2;

                if (_column != null)
                {
                    JoinType = Wall.ByType.NonMappedColumn;
                }
                else
                {
                    JoinType = Wall.ByType.Alias;
                }
            }
        }
Exemplo n.º 2
0
        public void DeselectBy(ByType type, object toDeselect)
        {
            Log.Info($"{Name}: DeselectBy(): {type}, {(toDeselect is int ? Convert.ToInt32(toDeselect).ToString() : toDeselect.ToString())}");
            if (WebDriverSettings.ApplyOutline)
            {
                Outline(true);
            }

            switch (type)
            {
            case ByType.Index:
                Control.DeselectByIndex((Convert.ToInt32(toDeselect) - 1));      //Zero-Based index
                break;

            case ByType.Text:
                Control.DeselectByText(toDeselect.ToString());
                break;

            case ByType.Value:
                Control.DeselectByValue(toDeselect.ToString());
                break;

            default:
                var msg = $"{Name}: Unsupported Selection Type={type} used for DeselectBy";
                Log.Error(msg);
                throw new Exception(msg);
            }

            if (OutlineApplied)
            {
                Outline(false);
            }
        }
Exemplo n.º 3
0
        internal ByArgument(System.String arg)
            : base(arg)
        {
            if (String.IsNullOrEmpty(arg))
            {
                arg = null;
            }

            if (CheckNull(Arg(() => arg, arg)))
            {
                if (arg.Split(new char[] { Text.DotChar }).Length > 2)
                {
                    chainException = new QueryTalkException(this,
                                                            QueryTalkExceptionType.InvalidColumnIdentifier,
                                                            String.Format("identifier = {0}", arg),
                                                            Text.Method.Identifier);
                    return;
                }

                var pair = new AliasColumnPair(arg);
                _alias  = pair.Alias;
                _column = pair.Column;

                if (_column != null)
                {
                    JoinType = Wall.ByType.NonMappedColumn;
                }
                else
                {
                    JoinType = Wall.ByType.Alias;
                }
            }

            SetArgType(arg);
        }
Exemplo n.º 4
0
        private static void SafeClick(IWebDriver driver, ByType bt, string searchStr)
        {
            bool        success = false;
            IWebElement elem;

            while (!success)
            {
                elem = FindByType(driver, bt, searchStr);
                try
                {
                    elem.Click();
                    success = true;
                }
                catch (StaleElementReferenceException)
                {
                    Console.WriteLine("Stale: " + searchStr);
                }
                catch (ElementClickInterceptedException)
                {
                    Console.WriteLine("Intercepted: " + searchStr);
                }
                catch (ElementNotInteractableException ex)
                {
                    Console.WriteLine(ex.Message);
                    Console.WriteLine(searchStr);
                    Console.WriteLine();
                }
            }
        }
Exemplo n.º 5
0
 public static Locator GetVariableLocator(string locatorFormat, ByType locatorType, string variableName, string variableValue)
 {
     return(GetVariableLocator(locatorFormat, locatorType, new Hashtable()
     {
         { variableName, variableValue }
     }));
 }
Exemplo n.º 6
0
        public IEnumerable <ByStatusInfo> GetByStatus(ByType type, int id)
        {
            var t  = _context.JiraTasks.Include(e => e.State).ToList();
            var t2 = new List <int>();

            switch (type)
            {
            case ByType.Sprint:
                t2 = _context.JiraSprintTasks.Where(e => e.SprintId == id).Select(e => e.TaskId).ToList();
                break;

            case ByType.Epic:
                t2 = _context.JiraEpicTasks.Where(e => e.EpicId == id).Select(e => e.TaskId).ToList();
                break;

            case ByType.Release:
                t2 = _context.JiraReleaseTasks.Where(e => e.ReleaseId == id).Select(e => e.TaskId).ToList();
                break;

            default:
                return(Enumerable.Empty <ByStatusInfo>());
            }

            return(t.Where(e => t2.Contains(e.Id))
                   .GroupBy(e => e.State)
                   .Select(e => new ByStatusInfo {
                State = e.Key.Name, Count = e.Count()
            }));
        }
Exemplo n.º 7
0
 internal ByArgument(System.Int32 arg)
     : base(arg)
 {
     _alias   = arg.ToString();
     JoinType = Wall.ByType.Alias;
     SetArgType(arg);
 }
Exemplo n.º 8
0
        public IEnumerable <ByTypeInfo> GetByType(ByType type)
        {
            var retVal = new List <ByTypeInfo>();

            for (int i = 1; i < 16; i++)
            {
                retVal.Add(GetByType(type, i));
            }

            return(retVal);
        }
Exemplo n.º 9
0
        protected override void DoWaitForCompleteStop()
        {
            m_WaitEvent.Set();

            m_Thread.Join();
            m_Thread = null;

            m_WaitEvent.Close();
            m_WaitEvent = null;

            m_ByType = new ByType();
        }
Exemplo n.º 10
0
        internal ByArgument(OfChainer arg)
            : base(arg)
        {
            if (CheckNull(Arg(() => arg, arg)))
            {
                Build     = arg.Build;
                _dbColumn = arg.Column;
                _column   = arg.Column.ColumnName;
                _alias    = arg.Column.OfAlias;
                JoinType  = Wall.ByType.MappedColumn;
            }

            SetArgType(arg);
        }
Exemplo n.º 11
0
        public static Locator GetVariableLocator(string locatorFormat, ByType locatorType, Hashtable variables)
        {
            string locatorValue      = locatorFormat;
            string finalLocatorValue = locatorFormat;

            foreach (var variableName in variables.Keys)
            {
                locatorValue      = locatorValue.Replace(Project.VariablePrefix + variableName.ToString(), variables[variableName].ToString());
                finalLocatorValue = LanguageResourceRepository.ReplaceLanguageVariables(String.Format(locatorValue, variables[variableName].ToString()));
            }

            return(new Locator(finalLocatorValue, locatorType));
            //return new Locator(locatorValue, locatorType);
        }
Exemplo n.º 12
0
        private static IWebElement FindByType(IWebDriver driver, ByType bt, string searchStr)
        {
            switch (bt)
            {
            case ByType.Id:
                return(driver.FindElement(By.Id(searchStr)));

            case ByType.XPath:
                return(driver.FindElement(By.XPath(searchStr)));

            case ByType.ClassName:
                return(driver.FindElement(By.ClassName(searchStr)));
            }
            return(null);
        }
Exemplo n.º 13
0
        public static OpenQA.Selenium.By Get(ByType locatorType, string expression, params string[] placeholders)
        {
            expression = string.Format(expression, placeholders);
            switch (locatorType.Name)
            {
            case "xpath":
                return(OpenQA.Selenium.By.XPath(expression));

            case "id":
                return(OpenQA.Selenium.By.Id(expression));

            case "name":
                return(OpenQA.Selenium.By.Name(expression));

            default:
                return(null);
            }
        }
Exemplo n.º 14
0
        public static IWebElement GetElement(IWebDriver _driver, ByType byType, string element)
        {
            By          selector = null;
            IWebElement query    = null;

            switch (byType)
            {
            case ByType.Css:
                selector = By.CssSelector(element);
                break;

            case ByType.Id:
                selector = By.Id(element);
                break;

            case ByType.Xml:
                selector = By.XPath(element);
                break;

            case ByType.ClassName:
                selector = By.ClassName(element);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(byType), byType, null);
            }

            try
            {
                query = _driver.FindElement(selector);
            }
            catch (NoSuchElementException nsex)
            {
                Console.WriteLine("Element couldn't be found: " + nsex);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }

            return(query ?? throw new Exception("GetElement returned a null value."));
        }
Exemplo n.º 15
0
        public void FindElementBy(ByType byType, string locator)
        {
            switch (byType)
            {
            case ByType.Id:
                Driver.FindElement(By.Id(locator)).Click();
                break;

            case ByType.LinkText:
                Driver.FindElement(By.LinkText(locator)).SendKeys(Keys.Enter);
                break;

            case ByType.PartialLinkText:
                Driver.FindElement(By.PartialLinkText(locator)).SendKeys(Keys.Enter);
                break;

            case ByType.XPath:
                Driver.FindElement(By.XPath(locator)).Click();
                break;
            }
        }
Exemplo n.º 16
0
        public void SelectBy(ByType type, object toSelect)
        {
            Log.Info($"{Name}: SelectBy(): {type}, {(toSelect is int ? Convert.ToInt32(toSelect).ToString() : toSelect.ToString())}");
            if (WebDriverSettings.ApplyOutline)
            {
                Outline(true);
            }

            switch (type)
            {
            case ByType.Index:
                var index = Convert.ToInt32(toSelect);
                if (index <= 0)
                {
                    var invalid = $"Invalid Index Value: {index} (Must be Greater than 0)";
                    Log.Error(invalid);
                    throw new Exception(invalid);
                }
                Control.SelectByIndex((Convert.ToInt32(toSelect) - 1));     //Zero-Based index
                break;

            case ByType.Text:
                Control.SelectByText(toSelect.ToString());
                break;

            case ByType.Value:
                Control.SelectByValue(toSelect.ToString());
                break;

            default:
                var msg = $"{Name}: Unsupported Selection Type={type} used for SelectBy";
                Log.Error(msg);
                throw new Exception(msg);
            }

            if (OutlineApplied)
            {
                Outline(false);
            }
        }
Exemplo n.º 17
0
        public ByTypeInfo GetByType(ByType type, int id)
        {
            var t  = _context.JiraTasks.Include(e => e.State).ToList();
            var t2 = new List <int>();

            switch (type)
            {
            case ByType.Sprint:
                t2 = _context.JiraSprintTasks.Where(e => e.SprintId == id).Select(e => e.TaskId).ToList();
                break;

            case ByType.Release:
                t2 = _context.JiraReleaseTasks.Where(e => e.ReleaseId == id).Select(e => e.TaskId).ToList();
                break;

            default:
                return(new ByTypeInfo());
            }

            var retVal =
                t.Where(e => t2.Contains(e.Id)).Select(e => new { IsDefect = e.DefectSeverity > 0 ? true : false, e.OriginalEstimation })
                .GroupBy(e => e.IsDefect)
                .Select(e => new { IsDefect = e.Key, DefectInCount = e.Count(), DefectsInStoryPoint = e.Sum(t => t.OriginalEstimation) });

            var total = retVal.Sum(e => e.DefectInCount);

            try
            {
                return(new ByTypeInfo
                {
                    DefectInPercent = (int)(retVal.Single(e => e.IsDefect).DefectInCount / (double)total * 100),
                    DefectsInStoryPoint = retVal.Single(e => e.IsDefect).DefectsInStoryPoint
                });
            }
            catch
            {
                return(new ByTypeInfo());
            }
        }
Exemplo n.º 18
0
        private static void SafeMenuClick(IWebDriver driver, WebDriverWait wait, ByType bt, string searchStr)
        {
            bool        success = false;
            IWebElement elem;

            while (!success)
            {
                elem = FindByType(driver, bt, searchStr);
                try
                {
                    wait.Until(ExpectedConditions.ElementToBeClickable(elem));
                    elem.Click();
                    success = true;
                }
                catch (StaleElementReferenceException)
                {
                    Console.WriteLine("Stale Menu: " + searchStr);
                }
                catch (WebDriverTimeoutException)
                {
                    Console.WriteLine("WebDriverTimeoutException: " + searchStr);
                }
            }
        }
Exemplo n.º 19
0
 private MainPageElement(ByType byType, string expression) : base(byType, expression)
 {
 }
Exemplo n.º 20
0
 private ResultsPageElement(ByType byType, string expression) : base(byType, expression)
 {
 }
Exemplo n.º 21
0
 public Parent(ByType byType, string byParam) : base(byType, byParam)
 {
 }
Exemplo n.º 22
0
#pragma warning disable CA1043
        internal TypeHandler this[Type type]
#pragma warning restore CA1043
        {
            get
            {
                if (ByType.TryGetValue(type, out var handler))
                {
                    return(handler);
                }

                // Try to find the backend type by a simple lookup on the given CLR type, this will handle base types.
                if (_postgresTypes.ByClrType.TryGetValue(type, out var postgresType))
                {
                    return(postgresType.Activate(this));
                }

                // Try to see if it is an array type
                var arrayElementType = GetArrayElementType(type);
                if (arrayElementType != null)
                {
                    if (ByType.TryGetValue(arrayElementType, out var elementHandler) &&
                        elementHandler.PostgresType.NpgsqlDbType.HasValue &&
                        ByNpgsqlDbType.TryGetValue(NpgsqlDbType.Array | elementHandler.PostgresType.NpgsqlDbType.Value, out handler))
                    {
                        return(handler);
                    }

                    // Enum and composite types go through the special _arrayHandlerByType
                    if (ArrayHandlerByType != null && ArrayHandlerByType.TryGetValue(arrayElementType, out handler))
                    {
                        return(handler);
                    }

                    // Unactivated array

                    // Special check for byte[] - bytea not array of int2
                    if (type == typeof(byte[]))
                    {
                        if (!_postgresTypes.ByClrType.TryGetValue(typeof(byte[]), out var byteaPostgresType))
                        {
                            throw new NpgsqlException("The PostgreSQL 'bytea' type is missing");
                        }
                        return(byteaPostgresType.Activate(this));
                    }

                    // Get the elements backend type and activate its array backend type
                    if (!_postgresTypes.ByClrType.TryGetValue(arrayElementType, out var elementPostgresType))
                    {
                        if (arrayElementType.GetTypeInfo().IsEnum)
                        {
                            throw new NotSupportedException($"The CLR enum type {arrayElementType.Name} must be mapped with Npgsql before usage, please refer to the documentation.");
                        }
                        throw new NotSupportedException($"The CLR type {arrayElementType} isn't supported by Npgsql or your PostgreSQL. " +
                                                        "If you wish to map it to a PostgreSQL composite type you need to register it before usage, please refer to the documentation.");
                    }

                    if (elementPostgresType == null)
                    {
                        throw new NotSupportedException($"The PostgreSQL {arrayElementType.Name} does not have an array type in the database");
                    }

                    return(elementPostgresType.Array.Activate(this));
                }

                // Range type which hasn't yet been set up
                if (type.GetTypeInfo().IsGenericType&& type.GetGenericTypeDefinition() == typeof(NpgsqlRange <>))
                {
                    if (!_postgresTypes.ByClrType.TryGetValue(type.GetGenericArguments()[0], out var subtypePostgresType) ||
                        subtypePostgresType.Range == null)
                    {
                        throw new NpgsqlException($"The .NET range type {type.Name} isn't supported in your PostgreSQL, use CREATE TYPE AS RANGE");
                    }

                    return(subtypePostgresType.Range.Activate(this));
                }

                // Nothing worked
                if (type.GetTypeInfo().IsEnum)
                {
                    throw new NotSupportedException($"The CLR enum type {type.Name} must be registered with Npgsql before usage, please refer to the documentation.");
                }

                if (typeof(IEnumerable).IsAssignableFrom(type))
                {
                    throw new NotSupportedException("Npgsql 3.x removed support for writing a parameter with an IEnumerable value, use .ToList()/.ToArray() instead");
                }

                throw new NotSupportedException($"The CLR type {type} isn't supported by Npgsql or your PostgreSQL. " +
                                                "If you wish to map it to a PostgreSQL composite type you need to register it before usage, please refer to the documentation.");
            }
        }
Exemplo n.º 23
0
 /// <summary>
 /// Another consturctor which initialize the 2 values
 /// </summary>
 /// <param name="value">Element locator string</param>
 /// <param name="byType">Element location type</param>
 public Locator(string value, ByType byType)
 {
     Value = value;
     Type  = byType;
 }
Exemplo n.º 24
0
 protected PageElement(ByType byType, string expression)
 {
     this.byType     = byType;
     this.expression = expression;
 }
Exemplo n.º 25
0
        public async Task <List <Stats> > GetStats(string startDate, string endDate = null, AggregatedBy aggregatedBy = null, ByType byType = null)
        {
            var endpoint = $"/stats?start_date={startDate}";

            if (!string.IsNullOrEmpty(endDate))
            {
                endpoint = $"{endpoint}&end_date={endDate}";
            }
            if (aggregatedBy != null)
            {
                endpoint = $"/stats?aggregated_by={aggregatedBy.Value}&start_date={startDate}";
            }
            if (aggregatedBy != null && !string.IsNullOrEmpty(endDate))
            {
                endpoint = $"/stats?aggregated_by={aggregatedBy.Value}&start_date={startDate}&end_date={endDate}";
            }

            if (byType != null)
            {
                endpoint = $"/{byType.Value}{endpoint}";
            }

            var(result, statusCode, message) = await _consumingApiHelper
                                               .AddBearerAuthentication(_apiKey)
                                               .GetAssync <List <Stats> >(endpoint);

            return(result);
        }
Exemplo n.º 26
0
 public Control(ByType byType, string byParam) : this(byType.ToString(), byParam)
 {
 }