Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VariableControllerTests"/> class.
 /// Инициализация переменных.
 /// </summary>
 public VariableControllerTests()
 {
     variableContext = new VariableController();
     variableContext.SetVariable("first", typeof(string), "1");
     variableContext.SetVariable("second", typeof(string), "2");
     variableContext.SetVariable("third", typeof(string), "3");
 }
Exemplo n.º 2
0
        public void SaveUrlActivePage(string varName)
        {
            variableController.Variables.Should().NotContainKey(varName, $"переменная \"{varName}\" уже существует");

            var url = BrowserController.GetBrowser().Url;

            variableController.SetVariable(varName, url.GetType(), url);
        }
        public void IsEnumerable_NotColl_ReturnException()
        {
            const int variable = 5;

            variableController.SetVariable("test", variable.GetType(), variable);
            Action act = () => "test".IsEnumerable(variableController);

            act.Should().Throw <Exception>()
            .Where(e => e.Message.Contains("\"test\" не является коллекцией"));
        }
Exemplo n.º 4
0
        public void ExecuteQuery(string connectionName, string varName, QueryParam query)
        {
            databaseController.Connections.InputValidation(connectionName, query.Query);

            var(connection, timeout) = databaseController.Connections.SingleOrDefault(_ => _.Key == connectionName).Value;
            var(outRecords, count)   = connection.ExecuteQuery(query.Query, timeout);
            Log.Logger().LogInformation($"Request returned: {Environment.NewLine} {(outRecords != null ? Message.CreateMessage((DataTable)outRecords) : $"is empty")}");
            Log.Logger().LogInformation($"Request {query} returned {count} row(s)");

            variableController.SetVariable(varName, typeof(DataTable), outRecords);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ReplaceTests"/> class.
        /// Инициализация переменных.
        /// </summary>
        public ReplaceTests()
        {
            variableContext = new VariableController();
            variableContext.SetVariable("int", typeof(int), 1);
            variableContext.SetVariable("long", typeof(long), 100);
            variableContext.SetVariable("double", typeof(double), 1.1);
            variableContext.SetVariable("bool", typeof(bool), true);

            var token = JToken.Parse("{\"first\":1,\"list\":[{\"second\":true},{\"third\":3}],\"four\":true}");

            variableContext.SetVariable("json", token.GetType(), token);

            var xml = new XmlDocument();

            xml.LoadXml("<?xml version=\"1.0\" encoding=\"UTF-8\"?><addresses xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:noNamespaceSchemaLocation='test.xsd'><address><name>Joe Tester</name><street>Baker street</street><house>5</house><bool>true</bool></address></addresses>");
            variableContext.SetVariable("xml", xml.GetType(), xml);
        }
Exemplo n.º 6
0
 public void EmtpyVariable(string varName)
 {
     variableController.Variables.Should().ContainKey(varName, $"переменная \"{varName}\" не существует");
     variableController.SetVariable(varName, typeof(object), null);
 }
Exemplo n.º 7
0
 public void CreateJson(string varName, JToken token)
 {
     variableController.SetVariable(varName, token.GetType(), token);
 }
Exemplo n.º 8
0
        public void GetVariableName_NameWithBracessAndPoint_ReturnName(string key, string name)
        {
            variableContext.SetVariable(key, typeof(string), "1");
            var varName = variableContext.GetVariableName(key);

            varName.Should().Be(name);
        }