private static void CheckGetAntExpressions(IList <string> actual, params string[] expected) { Assert.IsNotNull(actual); Assert.IsTrue(ArrayUtils.AreEqual( expected, new List <string>(actual).ToArray())); }
public void GetAntExpressionsWithAStringThatDoesntHaveAnyExpressions() { IList <string> actual = StringUtils.GetAntExpressions("I could really go a cup of tea right now... in fact I think I'll go get one."); Assert.IsNotNull(actual); string[] expected = new string[] {}; Assert.IsTrue(ArrayUtils.AreEqual(expected, new List <string>(actual).ToArray())); }
public void GetAntExpressionsWithEmptyString() { IList <string> actual = StringUtils.GetAntExpressions(String.Empty); Assert.IsNotNull(actual); string[] expected = new string[] {}; Assert.IsTrue(ArrayUtils.AreEqual(expected, new List <string>(actual).ToArray())); }
public void AreEqual() { object [] one = new string [] { "Foo", "Bar", "Baz" }; object [] two = new string [] { "Foo", "Bar", "Baz" }; Assert.IsTrue(ArrayUtils.AreEqual(one, two)); object [] three = new string [] { "Foo", "Ben", "Baz" }; Assert.IsFalse(ArrayUtils.AreEqual(one, three)); }
public void AreEqualWithBadArguments() { Assert.IsTrue(ArrayUtils.AreEqual(null, null)); object [] one = new string [] { "Foo", "Bar", "Baz" }; object [] two = null; Assert.IsFalse(ArrayUtils.AreEqual(one, two)); object [] three = new string [] { "Foo", "Bar" }; Assert.IsFalse(ArrayUtils.AreEqual(one, three)); }
public void SplitTests() { string testString = " a,b,, c ,d\n:e "; string delim = ",\n"; string[] res; string[] res1 = new string[] { " a", "b", "", " c ", "d", ":e " }; string[] res2 = new string[] { " a", "b", " c ", "d", ":e " }; string[] res3 = new string[] { "a", "b", "", "c", "d", ":e" }; string[] res4 = new string[] { "a", "b", "c", "d", ":e" }; Assert.AreEqual(0, StringUtils.Split(null, null, false, false).Length); Assert.AreEqual(testString, StringUtils.Split(testString, null, false, false)[0]); Assert.IsTrue(ArrayUtils.AreEqual(res1, res = StringUtils.Split(testString, delim, false, false)), "Received '" + String.Join(",", res) + "'"); Assert.IsTrue(ArrayUtils.AreEqual(res2, res = StringUtils.Split(testString, delim, false, true)), "Received '" + String.Join(",", res) + "'"); Assert.IsTrue(ArrayUtils.AreEqual(res3, res = StringUtils.Split(testString, delim, true, false)), "Received '" + String.Join(",", res) + "'"); Assert.IsTrue(ArrayUtils.AreEqual(res4, res = StringUtils.Split(testString, delim, true, true)), "Received '" + String.Join(",", res) + "'"); Assert.IsTrue(ArrayUtils.AreEqual(new string[] { "one" }, res = StringUtils.Split("one", delim, true, true)), "Received '" + String.Join(",", res) + "'"); }