Skip to content

Commit 848635c

Browse files
committed
updated tests
1 parent 2edb885 commit 848635c

1 file changed

Lines changed: 16 additions & 100 deletions

File tree

tests/PolylineAlgorithm.Tests/PolylineTest.cs

Lines changed: 16 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -40,40 +40,6 @@ public void Constructor_Parameterless_Ok() {
4040
Assert.IsTrue(polyline.Value.IsEmpty);
4141
}
4242

43-
/// <summary>
44-
/// Tests the <see cref="Polyline"/> constructor with a null string, expecting an <see cref="ArgumentNullException"/>.
45-
/// </summary>
46-
[TestMethod]
47-
public void Constructor_Null_String_ArgumentNullException() {
48-
// Arrange
49-
string value = null!;
50-
51-
// Act
52-
static Polyline New(string value) => Polyline.FromString(value);
53-
54-
// Assert
55-
Assert.ThrowsExactly<ArgumentNullException>(() => New(value));
56-
}
57-
58-
/// <summary>
59-
/// Tests the <see cref="Polyline"/> constructor with a string parameter.
60-
/// </summary>
61-
/// <param name="value">The string value.</param>
62-
[TestMethod]
63-
[DynamicData(nameof(LengthParameters))]
64-
public void Constructor_String_Parameter_Ok(int length) {
65-
// Arrange
66-
var value = RandomValueProvider.GetPolyline(length);
67-
68-
// Act
69-
Polyline result = Polyline.FromString(value);
70-
71-
// Assert
72-
Assert.AreEqual(value.Length, result.Length);
73-
Assert.AreEqual(value.Length == 0, result.IsEmpty);
74-
Assert.AreEqual(value, result.ToString());
75-
}
76-
7743
/// <summary>
7844
/// Tests the <see cref="Polyline"/> constructor with a null character array, expecting an <see cref="ArgumentNullException"/>.
7945
/// </summary>
@@ -132,68 +98,13 @@ public void FromMemory_Memory_Parameter_Ok(int size) {
13298
Assert.AreEqual(polyline.ToString(), result.ToString());
13399
}
134100

135-
/// <summary>
136-
/// Tests the <see cref="Polyline.FromString(string)"/> method.
137-
/// </summary>
138-
/// <param name="value">The string value.</param>
139-
[TestMethod]
140-
[DynamicData(nameof(LengthParameters))]
141-
public void FromString_Equals_New(int size) {
142-
// Arrange
143-
var polyline = RandomValueProvider.GetPolyline(size);
144-
bool isEmpty = polyline.Length == 0;
145-
long length = polyline.Length;
146-
147-
// Act
148-
Polyline result = Polyline.FromString(polyline);
149-
150-
// Assert
151-
Assert.AreEqual(polyline, result.ToString());
152-
}
153-
154-
/// <summary>
155-
/// Tests the <see cref="Polyline.FromCharArray(char[])"/> method.
156-
/// </summary>
157-
/// <param name="value">The string value.</param>
158-
[TestMethod]
159-
[DynamicData(nameof(LengthParameters))]
160-
public void FromCharArray_Equals_New(int size) {
161-
// Arrange
162-
char[] array = RandomValueProvider.GetPolyline(size).ToCharArray();
163-
Polyline polyline = Polyline.FromCharArray(array);
164-
165-
// Act
166-
Polyline result = Polyline.FromCharArray(array);
167-
168-
// Assert
169-
Assert.IsTrue(polyline.Equals(result));
170-
}
171-
172-
/// <summary>
173-
/// Tests the <see cref="Polyline.FromMemory(ReadOnlyMemory{char})"/> method.
174-
/// </summary>
175-
/// <param name="value">The string value.</param>
176-
[TestMethod]
177-
[DynamicData(nameof(LengthParameters))]
178-
public void FromMemory_Equals_New(int size) {
179-
// Arrange
180-
ReadOnlyMemory<char> memory = RandomValueProvider.GetPolyline(size).AsMemory();
181-
Polyline polyline = Polyline.FromMemory(memory);
182-
183-
// Act
184-
Polyline result = Polyline.FromMemory(memory);
185-
186-
// Assert
187-
Assert.IsTrue(polyline.Equals(result));
188-
}
189-
190101
/// <summary>
191102
/// Tests the <see cref="Polyline.ToString"/> method.
192103
/// </summary>
193104
/// <param name="value">The string value.</param>
194105
[TestMethod]
195106
[DynamicData(nameof(LengthParameters))]
196-
public void ToString_Equals_Constructor_Parameter(int size) {
107+
public void ToString_Returns_Correct_String(int size) {
197108
// Arrange
198109
Polyline polyline = Polyline.FromString(RandomValueProvider.GetPolyline(size));
199110
string expected = RandomValueProvider.GetPolyline(size);
@@ -211,7 +122,7 @@ public void ToString_Equals_Constructor_Parameter(int size) {
211122
/// <param name="value">The string value.</param>
212123
[TestMethod]
213124
[DynamicData(nameof(LengthParameters))]
214-
public void CopyTo_Equals_Expected_Value(int size) {
125+
public void CopyTo_Equals_Correct_CharArray(int size) {
215126
// Arrange
216127
Polyline polyline = Polyline.FromString(RandomValueProvider.GetPolyline(size));
217128
char[] expected = RandomValueProvider.GetPolyline(size).ToCharArray();
@@ -263,19 +174,24 @@ public void CopyTo_Null_Destination_Parameter_Throws_ArgumentNullException(int s
263174
}
264175

265176
[TestMethod]
266-
public void Equality_Operators_OK() {
177+
public void Equality_Operators_Correct_Results() {
267178
// Arrange
268-
Polyline first = Polyline.FromString(nameof(first));
269-
Polyline equal = Polyline.FromString(nameof(first));
179+
Polyline polyline = Polyline.FromString(nameof(polyline));
180+
Polyline equal = Polyline.FromString(nameof(polyline));
270181
Polyline notEqual = Polyline.FromString(nameof(notEqual));
182+
string typeNotEqual = "not a polyline";
271183

272184
// Act && Assert
273-
Assert.IsTrue(first == equal);
274-
Assert.IsTrue(first != notEqual);
275-
Assert.IsTrue(first.Equals(equal));
185+
Assert.IsTrue(polyline == equal);
186+
Assert.IsTrue(polyline != notEqual);
187+
188+
Assert.IsFalse(polyline != equal);
189+
Assert.IsFalse(polyline == notEqual);
190+
191+
Assert.IsTrue(polyline.Equals(equal));
192+
Assert.IsTrue(polyline.Equals((object)equal));
276193

277-
Assert.IsFalse(first != equal);
278-
Assert.IsFalse(first == notEqual);
279-
Assert.IsFalse(first.Equals(notEqual));
194+
Assert.IsFalse(polyline.Equals((object)notEqual));
195+
Assert.IsFalse(polyline.Equals(typeNotEqual));
280196
}
281197
}

0 commit comments

Comments
 (0)