public void ReplaceTest() { string formatString = "Hello,[Person], you are a good [[job]]"; IDictionary<string, string> replacePattern = new Dictionary<string, string> { {"Person", "John"}, {"job", "student"} }; string expected = "Hello,John, you are a good [student]"; string actual; var target = new NamedFormatterHelper(); actual = target.Replace(formatString, replacePattern); Assert.AreEqual(expected, actual); }
public void CollectVariableTest() { string content = @"string [a] ok [b.a]kdjfkdjfkdj [a][b] [c]isAGood[a]"; var expected = new[] { "a", "b.a", "c", "b" }; string[] actual; var a = new NamedFormatterHelper(); actual = a.CollectVariable(content); Assert.AreEqual(expected.Length, actual.Length); for (int idx = 0; idx < actual.Length; idx++) { int aryIndex = Array.IndexOf(expected, actual[idx]); Assert.AreNotEqual(-1, aryIndex, expected[idx] + " isn't in expected array"); } }