1: [TestFixture]
2: public class sequence_of_strings_Concatenate
3: { 4: string[] sequence;
5:
6: [SetUp]
7: public void SetUp()
8: { 9: this.OnSetUp();
10: }
11:
12: protected virtual void OnSetUp()
13: { 14: sequence = new string[] { "a", "b", "c" }; 15: }
16:
17: [Test, ExpectedException(typeof(ArgumentNullException))]
18: public void should_throw_exception_when_sequence_is_null()
19: { 20: Legend.Collections.Collection.Concatenate(null);
21: }
22:
23: [Test]
24: public void should_concatenate_values()
25: { 26: var result = sequence.Concatenate();
27: Assert.AreEqual(result, "abc");
28: }
29: }
30:
31: [TestFixture]
32: public class sequence_of_strings_Concatenate_with_specified_separator
33: { 34: string[] sequence;
35:
36: [SetUp]
37: public void SetUp()
38: { 39: this.OnSetUp();
40: }
41:
42: protected virtual void OnSetUp()
43: { 44: sequence = new string[] { "a", "b", "c" }; 45: }
46:
47: [Test, ExpectedException(typeof(ArgumentNullException))]
48: public void should_throw_exception_when_sequence_is_null()
49: { 50: Legend.Collections.Collection.Concatenate(null, ",");
51: }
52:
53: [Test, ExpectedException(typeof(ArgumentNullException))]
54: public void should_throw_exception_when_separator_is_null()
55: { 56: sequence.Concatenate(null);
57: }
58:
59: [Test]
60: public void should_concatenate_values_separated_by_separator()
61: { 62: var result = sequence.Concatenate(", "); 63: Assert.AreEqual(result, "a, b, c");
64: }
65: }
66:
67: [TestFixture]
68: public class sequence_of_strings_Concatenate_with_specified_separator_prefix_and_suffix
69: { 70: string[] sequence;
71:
72: [SetUp]
73: public void SetUp()
74: { 75: this.OnSetUp();
76: }
77:
78: protected virtual void OnSetUp()
79: { 80: sequence = new string[] { "a", "b", "c" }; 81: }
82:
83: [Test, ExpectedException(typeof(ArgumentNullException))]
84: public void should_throw_exception_when_sequence_is_null()
85: { 86: Legend.Collections.Collection.Concatenate(null, ",", string.Empty, string.Empty);
87: }
88:
89: [Test, ExpectedException(typeof(ArgumentNullException))]
90: public void should_throw_exception_when_separator_is_null()
91: { 92: sequence.Concatenate(null, string.Empty, string.Empty);
93: }
94:
95: [Test, ExpectedException(typeof(ArgumentNullException))]
96: public void should_throw_exception_when_prefix_is_null()
97: { 98: sequence.Concatenate(string.Empty, null, string.Empty);
99: }
100:
101: [Test, ExpectedException(typeof(ArgumentNullException))]
102: public void should_throw_exception_when_suffix_is_null()
103: { 104: sequence.Concatenate(string.Empty, string.Empty, null);
105: }
106:
107: [Test]
108: public void should_concatenate_string_with_separator_prefix_and_suffix_appended()
109: { 110: var result = sequence.Concatenate(", ", "(", ")"); 111: Assert.AreEqual("(a, b, c)", result); 112: }
113: }