Ejemplo n.º 1
0
        public void StoreAsVariableString(string text, string varName)
        {
            var str = variableController.ReplaceVariables(text);

            Log.Logger().LogDebug($"Replaced text with variables is equal to {Environment.NewLine}{str}");
            variableController.SetVariable(varName, typeof(string), str);
        }
Ejemplo n.º 2
0
        private int GetTimeout()
        {
            var headerValue = headers.FirstOrDefault(h => h.Style == HeaderType.TIMEOUT)?.Value;
            var value       = variableController.ReplaceVariables(headerValue) ?? headerValue;

            return(int.Parse(value));
        }
Ejemplo n.º 3
0
        public void UploadFileIntoField(string name, string fullpath)
        {
            fullpath = variableController.ReplaceVariables(fullpath) ?? fullpath;

            var element = BrowserController.GetBrowser().GetCurrentPage().GetElement(name);

            (element is File).Should().BeTrue($"элемент \"{name}\" имеет отличный от File профиль");

            (element as File)?.SetText(fullpath);
        }
Ejemplo n.º 4
0
        public static IEnumerable <object> ToEnumerable(this Table table, VariableController variableController)
        {
            var enumerable = new List <object>();

            table.Rows.ToList().Count.Should().Be(0, "Table must have only 1 row: Values");
            foreach (var value in table.Header.ToList())
            {
                enumerable.Add(variableController.ReplaceVariables(value) ?? value);
            }
            return(enumerable);
        }
Ejemplo n.º 5
0
        private string GetBody()
        {
            var isCheck = headers.Count(h => h.Style == HeaderType.BODY);

            if (isCheck == 1)
            {
                var name  = headers.FirstOrDefault(h => h.Style == HeaderType.BODY).Value;
                var value = variableController.GetVariableValueText(name);
                return(value != null?variableController.ReplaceVariables(value) : name);
            }
            return(null);
        }
Ejemplo n.º 6
0
        public static Dictionary <string, object> ToDictionary(this Table table, VariableController variableController)
        {
            var enumerable = new Dictionary <string, object>();
            var keys       = table.Header.ToList();

            table.Rows.ToList().Count.Should().Be(1, "Table must have only 2 rows: Keys and Values");
            var values = table.Rows.ToList()[0];

            for (var i = 0; i < keys.Count; i++)
            {
                enumerable.Add(variableController.ReplaceVariables(keys[i]) ?? keys[i], variableController.ReplaceVariables(values[i]) ?? values[i]);
            }
            return(enumerable);
        }
        private Table ReplaceTableContent(Table dataTable)
        {
            var table = new Table(dataTable.Header.ToArray());

            dataTable.Rows.ToList().ForEach(row =>
            {
                var tr = new List <string>();
                row.Values.ToList().ForEach(elem =>
                {
                    tr.Add(variableController.ReplaceVariables(elem));
                });
                table.AddRow(tr.ToArray());
                tr.Clear();
            });
            return(table);
        }
Ejemplo n.º 8
0
        public static Table ReplaceWith(this Table table, VariableController variableController)
        {
            var dt = new Table(table.Header.ToArray());

            table.Rows.ToList().ForEach(row =>
            {
                var tr = new List <string>();
                row.Values.ToList().ForEach(elem =>
                {
                    tr.Add(variableController.ReplaceVariables(elem));
                });
                dt.AddRow(tr.ToArray());
                tr.Clear();
            });
            return(dt);
        }
Ejemplo n.º 9
0
        public void SendToRestServiceWithBody(string name, string url, HTTPMethodType method, RequestDto requestDto)
        {
            this.variableController.Variables.Should().NotContainKey($"Данные по сервису с именем \"{name}\" уже существуют");
            this.serviceController.Services.Should().NotContainKey($"Данные по сервису с именем \"{name}\" уже существуют");

            url = variableController.ReplaceVariables(url);

            if (requestDto.Query.Any())
            {
                url = url.AddQueryInURL(requestDto.Query);
            }

            if (!Uri.TryCreate(url, UriKind.Absolute, out Uri outUrl))
            {
                Log.Logger().LogWarning($"Url {url} is not valid.");
                throw new ArgumentException($"Url {url} is not valid.");
            }

            var request = new RequestInfo
            {
                Content = requestDto.Content,
                Headers = requestDto.Header,
                Method  = webMethods[method],
                Url     = url
            };

            using (var service = new WebService())
            {
                var responce = service.SendMessage(request).Result;

                if (responce != null)
                {
                    this.serviceController.Services.TryAdd(name, responce);
                }
                else
                {
                    Log.Logger().LogInformation($"Сервис с названием \"{name}\" не добавлен. Подробности в логах");
                }
            }
        }
Ejemplo n.º 10
0
        public void ReplaceVariables_currentDateTime_ReturnReplaced()
        {
            const string str    = "{{currentDateTime(dd-MM-yyyy)}}";
            var          outStr = variableContext.ReplaceVariables(str);

            Log.Logger().LogWarning($"ReplaceVariables_currentDateTime_ReturnReplaced - {outStr}");
            Assert.True(DateTime.TryParseExact(outStr, "dd-MM-yyyy",
                                               new CultureInfo("en-US"),
                                               DateTimeStyles.None,
                                               out _));
        }
Ejemplo n.º 11
0
 public JToken StringToJToken(string str)
 {
     str = variableController.ReplaceVariables(str);
     return(str.ToJson());
 }
Ejemplo n.º 12
0
        public void ReplaceVariables_JsonWithParseInt_ReturnReplacedJson(string json, string validJson)
        {
            var outJson = variableContext.ReplaceVariables(json);

            Assert.Equal(outJson, validJson);
        }
Ejemplo n.º 13
0
 public QueryParam TransformationQuery(string query)
 {
     return(new QueryParam {
         Query = variableController.ReplaceVariables(query)
     });
 }