Exemplo n.º 1
0
 public void SeparatorsCanBeEmpty()
 {
     Assert.AreEqual("1,2", StringJoinExtensions.JoinAnd(
                         new[] { "1", "2" }, "", ","), "separator is empty");
     Assert.AreEqual("12", StringJoinExtensions.JoinAnd(
                         new[] { "1", "2" }, ",", ""), "last separator is empty");
     Assert.AreEqual("12", StringJoinExtensions.JoinAnd(
                         new[] { "1", "2" }, "", ""), "both separators are empty");
 }
Exemplo n.º 2
0
        public void ThrowsIfArgumentNulls()
        {
            string[] values = default;
            Assert.ThrowsException <ArgumentNullException>(() =>
                                                           StringJoinExtensions.JoinAnd(values, ", ", " and "));

            Assert.ThrowsException <ArgumentNullException>(() =>
                                                           StringJoinExtensions.JoinAnd(new[] { "1", "2" }, null,
                                                                                        " and "));
        }
Exemplo n.º 3
0
        public void ValuesCanBeNullOrEmpty()
        {
            Assert.AreEqual("-2", StringJoinExtensions.JoinAnd(
                                new[] { "", "2" }, "+", "-"), "1st value is empty");
            Assert.AreEqual("1-", StringJoinExtensions.JoinAnd(
                                new[] { "1", "" }, "+", "-"), "2nd value is empty");
            Assert.AreEqual("1+2-", StringJoinExtensions.JoinAnd(
                                new[] { "1", "2", "" }, "+", "-"), "3rd value is empty");

            Assert.AreEqual("-2", StringJoinExtensions.JoinAnd(
                                new[] { null, "2" }, "+", "-"), "1st value is null");
            Assert.AreEqual("1-", StringJoinExtensions.JoinAnd(
                                new[] { "1", null }, "+", "-"), "2nd value is null");
            Assert.AreEqual("1+2-", StringJoinExtensions.JoinAnd(
                                new[] { "1", "2", null }, "+", "-"), "3rd value is null");
        }