1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
/**
* Copyright (c) David Miller. All rights reserved.
* The use and distribution terms for this software are covered by the
* Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
* which can be found in the file epl-v10.html at the root of this distribution.
* By using this software in any fashion, you are agreeing to be bound by
* the terms of this license.
* You must not remove this notice, or any other, from this software.
**/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Rhino.Mocks;
using clojure.lang;
using RMExpect = Rhino.Mocks.Expect;
namespace Clojure.Tests.LibTests
{
[TestFixture]
public class StringSeqTests : AssertionHelper
{
#region C-tor tests
[Test]
public void Create_on_empty_string_yields_null()
{
StringSeq s = StringSeq.create(String.Empty);
Expect(s, Null);
}
[Test]
public void Create_on_nonempty_string_yields_a_StringSeq()
{
StringSeq s = StringSeq.create("abcde");
Expect(s, Not.Null);
}
#endregion
#region IPersistentCollection tests
[Test]
public void Count_is_string_length()
{
StringSeq s = StringSeq.create("abcde");
Expect(s.count(),EqualTo(5));
}
#endregion
#region IndexedSeq tests
[Test]
public void Initial_index_is_zero()
{
StringSeq s = StringSeq.create("abc");
Expect(s.index(), EqualTo(0));
}
[Test]
public void Index_of_rest_is_one()
{
StringSeq s = StringSeq.create("abc");
IndexedSeq i = (IndexedSeq)s.rest();
Expect(i.index(), EqualTo(1));
}
#endregion
}
[TestFixture]
public class StringSeq_ISeq_Tests : ISeqTestHelper
{
StringSeq _s;
StringSeq _sWithMeta;
object[] _values;
[SetUp]
public void Setup()
{
IPersistentMap meta = PersistentHashMap.create("a", 1, "b", 2);
_s = StringSeq.create("abcde");
_sWithMeta = (StringSeq)((IObj)StringSeq.create("abcde")).withMeta(meta);
_values = new object[] { 'a', 'b', 'c', 'd', 'e' };
}
[Test]
public void StringSeq_has_correct_ISeq_values()
{
VerifyISeqContents(_s, _values);
}
[Test]
public void StringSeq_with_meta_has_correct_ISeq_values()
{
VerifyISeqContents(_sWithMeta, _values);
}
[Test]
public void StringSeq_ISeq_rest_preserves_meta()
{
VerifyISeqRestMaintainsMeta(_sWithMeta);
}
[Test]
public void StringSeq_ISeq_rest_preserves_type()
{
VerifyISeqRestTypes(_s,typeof(StringSeq));
}
[Test]
public void StringSeq_ISeq_cons_works()
{
VerifyISeqCons(_s, 12, _values);
}
}
[TestFixture]
public class StringSeq_IObj_Tests : IObjTests
{
MockRepository _mocks;
[SetUp]
public void Setup()
{
_mocks = new MockRepository();
IPersistentMap meta = _mocks.StrictMock<IPersistentMap>();
_mocks.ReplayAll();
StringSeq s = StringSeq.create("abcde");
_objWithNullMeta = (IObj)s;
_obj = _objWithNullMeta.withMeta(meta);
_expectedType = typeof(StringSeq);
}
[TearDown]
public void Teardown()
{
_mocks.VerifyAll();
}
}
}
|