public void ReplaceStringsTest() { Condition_Accessor target = new Condition_Accessor(); string s = "neco = 'test text' 'trololoooo' like 'neco' [pokus]"; Dictionary <string, string> dictionary = null; Dictionary <string, string> dictionaryExpected = new Dictionary <string, string>(); dictionaryExpected.Add("$0$", "test text"); dictionaryExpected.Add("$1$", "trololoooo"); dictionaryExpected.Add("$2$", "neco"); dictionaryExpected.Add("$3$", "pokus"); string expected = "neco = $0$ $1$ like $2$ $3$"; string actual; actual = target.ReplaceStrings(s, out dictionary); foreach (KeyValuePair <string, string> pair in dictionaryExpected) { if (pair.Value != dictionary[pair.Key]) { Assert.Fail("spatny slovnik stringu"); } } Assert.AreEqual(expected, actual); }
public void ReplaceStringsTest() { Condition_Accessor target = new Condition_Accessor(); string s = "neco = 'test text' 'trololoooo' like 'neco' [pokus]"; Dictionary<string, string> dictionary = null; Dictionary<string, string> dictionaryExpected = new Dictionary<string, string>(); dictionaryExpected.Add("$0$", "test text"); dictionaryExpected.Add("$1$", "trololoooo"); dictionaryExpected.Add("$2$", "neco"); dictionaryExpected.Add("$3$", "pokus"); string expected = "neco = $0$ $1$ like $2$ $3$"; string actual; actual = target.ReplaceStrings(s, out dictionary); foreach (KeyValuePair<string, string> pair in dictionaryExpected) { if (pair.Value != dictionary[pair.Key]) { Assert.Fail("spatny slovnik stringu"); } } Assert.AreEqual(expected, actual); }
public void CompareValuesTest() { Condition_Accessor target = new Condition_Accessor(); object ValueInRow = null; string ValueInCondition = string.Empty; OperatorType operatorType = new OperatorType(); bool expected = false; bool actual; actual = target.CompareValues(ValueInRow, ValueInCondition, operatorType); Assert.AreEqual(expected, actual); }
private static void Check(Condition_Accessor target, string podminka, ColumnCollection cols, object left, object right, Operators op) { target.ParseString(podminka, cols); if (target.compare_operator != op) { Fail(podminka, "spatne urceny operator"); } if (!left.Equals(target.left_value)) { Fail(podminka, "leva strana spatne urcena"); } if (!right.Equals(target.right_value)) { Fail(podminka, "prava strana spatne urcena"); } }
public void parseStringTest() { Condition_Accessor target = new Condition_Accessor(); // TODO: Initialize to an appropriate value ColumnCollection grid_columns = new ColumnCollection(); grid_columns.Add(new TextColumn("Sloupec 1")); grid_columns.Add(new TextColumn("Sloupec 2")); grid_columns.Add(new NumberColumn("Sloupec 3")); grid_columns.Add(new NumberColumn("cislo")); grid_columns.Add(new TextColumn("Sloupec like")); Check(target, "[Sloupec 1] = 100", grid_columns, grid_columns[0], "100", Operators.equal); Check(target, "cislo > 56", grid_columns, grid_columns[3], "56", Operators.greater_than); Check(target, "cislo >= '56'", grid_columns, grid_columns[3], "56", Operators.greater_than | Operators.equal); Check(target, "[Sloupec 2] LIKE '160%'", grid_columns, grid_columns[1], "160%", Operators.like); Check(target, "[Sloupec 2] like '160%'", grid_columns, grid_columns[1], "160%", Operators.like); Check(target, "Sloupec 2 like '160%'", grid_columns, grid_columns[1], "160%", Operators.like); Check(target, "Sloupec 2 like 'neco = pokus'", grid_columns, grid_columns[1], "neco = pokus", Operators.like); Check(target, "Sloupec 1 REGeXp 'neco.*'", grid_columns, grid_columns[0], "neco.*", Operators.regexp); Check(target, "[Sloupec like] like '160%'", grid_columns, grid_columns[4], "160%", Operators.like); }