Skip to content

Commit a303e67

Browse files
committed
fixed extensi0ons tests
1 parent 111327e commit a303e67

2 files changed

Lines changed: 21 additions & 29 deletions

File tree

tests/PolylineAlgorithm.Tests/Extensions/PolylineDecoderExtensionsTests.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright © Pete Sramek. All rights reserved.
33
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
44
//
@@ -48,7 +48,7 @@ public void Decode_StringWithNullDecoder_ThrowsArgumentNullException()
4848
string polyline = "test";
4949

5050
// Act & Assert
51-
ArgumentNullException exception = Assert.ThrowsExactly<ArgumentNullException>(() => decoder!.Decode(polyline));
51+
ArgumentNullException exception = Assert.ThrowsExactly<ArgumentNullException>(() => PolylineDecoderExtensions.Decode(decoder!, polyline));
5252
Assert.AreEqual("decoder", exception.ParamName);
5353
}
5454

@@ -65,18 +65,18 @@ public void Decode_StringWithValidDecoder_CallsDecoderWithPolylineFromString()
6565
[
6666
new Coordinate(38.5, -120.2),
6767
new Coordinate(40.7, -120.95),
68-
new Coordinate(43.252, -126.453)
68+
new Coordinate(43.252, -126.453),
6969
];
7070
var decoder = new TestPolylineDecoder(expectedCoordinates);
7171

7272
// Act
73-
IEnumerable<Coordinate> result = decoder.Decode(polylineString);
73+
IEnumerable<Coordinate> result = PolylineDecoderExtensions.Decode(decoder, polylineString);
7474

7575
// Assert
7676
Assert.IsNotNull(result);
7777
Coordinate[] coordinates = result.ToArray();
78-
Assert.AreEqual(3, coordinates.Length);
79-
Assert.AreSame(decoder.LastPolyline, Polyline.FromString(polylineString));
78+
Assert.HasCount(3, coordinates);
79+
Assert.AreEqual(decoder.LastPolyline, Polyline.FromString(polylineString));
8080
}
8181

8282
/// <summary>
@@ -91,7 +91,7 @@ public void Decode_CharArrayWithNullDecoder_ThrowsArgumentNullException()
9191
char[] polyline = ['t', 'e', 's', 't'];
9292

9393
// Act & Assert
94-
ArgumentNullException exception = Assert.ThrowsExactly<ArgumentNullException>(() => decoder!.Decode(polyline));
94+
ArgumentNullException exception = Assert.ThrowsExactly<ArgumentNullException>(() => PolylineDecoderExtensions.Decode(decoder!, polyline));
9595
Assert.AreEqual("decoder", exception.ParamName);
9696
}
9797

@@ -111,7 +111,7 @@ public void Decode_CharArrayWithValidDecoder_CallsDecoderWithPolylineFromCharArr
111111
var decoder = new TestPolylineDecoder(expectedCoordinates);
112112

113113
// Act
114-
IEnumerable<Coordinate> result = decoder.Decode(polylineChars);
114+
IEnumerable<Coordinate> result = PolylineDecoderExtensions.Decode(decoder, polylineChars);
115115

116116
// Assert
117117
Assert.IsNotNull(result);
@@ -132,7 +132,7 @@ public void Decode_ReadOnlyMemoryWithNullDecoder_ThrowsArgumentNullException()
132132
ReadOnlyMemory<char> polyline = "test".AsMemory();
133133

134134
// Act & Assert
135-
ArgumentNullException exception = Assert.ThrowsExactly<ArgumentNullException>(() => decoder!.Decode(polyline));
135+
ArgumentNullException exception = Assert.ThrowsExactly<ArgumentNullException>(() => PolylineDecoderExtensions.Decode(decoder!, polyline));
136136
Assert.AreEqual("decoder", exception.ParamName);
137137
}
138138

@@ -152,7 +152,7 @@ public void Decode_ReadOnlyMemoryWithValidDecoder_CallsDecoderWithPolylineFromMe
152152
var decoder = new TestPolylineDecoder(expectedCoordinates);
153153

154154
// Act
155-
IEnumerable<Coordinate> result = decoder.Decode(polylineMemory);
155+
IEnumerable<Coordinate> result = PolylineDecoderExtensions.Decode(decoder, polylineMemory);
156156

157157
// Assert
158158
Assert.IsNotNull(result);

tests/PolylineAlgorithm.Tests/Extensions/PolylineEncoderExtensionsTests.cs

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//
1+
//
22
// Copyright © Pete Sramek. All rights reserved.
33
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
44
//
@@ -30,7 +30,7 @@ public void Encode_ListWithNullEncoder_ThrowsArgumentNullException()
3030
List<Coordinate> coordinates = [new Coordinate(38.5, -120.2)];
3131

3232
// Act & Assert
33-
ArgumentNullException exception = Assert.ThrowsExactly<ArgumentNullException>(() => encoder!.Encode(coordinates));
33+
ArgumentNullException exception = Assert.ThrowsExactly<ArgumentNullException>(() => PolylineEncoderExtensions.Encode(encoder!, coordinates));
3434
Assert.AreEqual("encoder", exception.ParamName);
3535
}
3636

@@ -46,7 +46,7 @@ public void Encode_ListWithNullCoordinates_ThrowsArgumentNullException()
4646
List<Coordinate>? coordinates = null;
4747

4848
// Act & Assert
49-
ArgumentNullException exception = Assert.ThrowsExactly<ArgumentNullException>(() => encoder.Encode(coordinates!));
49+
ArgumentNullException exception = Assert.ThrowsExactly<ArgumentNullException>(() => PolylineEncoderExtensions.Encode(encoder, coordinates!));
5050
Assert.AreEqual("coordinates", exception.ParamName);
5151
}
5252

@@ -68,7 +68,7 @@ public void Encode_ListWithValidEncoder_CallsEncoderWithCoordinatesFromList()
6868
PolylineEncoder encoder = new();
6969

7070
// Act
71-
Polyline result = encoder.Encode(coordinates);
71+
Polyline result = PolylineEncoderExtensions.Encode(encoder, coordinates);
7272

7373
// Assert
7474
Assert.AreEqual(expectedPolyline, result);
@@ -83,14 +83,10 @@ public void Encode_ListWithEmptyList_CallsEncoderWithEmptySpan()
8383
{
8484
// Arrange
8585
List<Coordinate> coordinates = [];
86-
Polyline expectedPolyline = Polyline.FromString("");
8786
PolylineEncoder encoder = new();
8887

89-
// Act
90-
Polyline result = encoder.Encode(coordinates);
91-
92-
// Assert
93-
Assert.AreEqual(expectedPolyline, result);
88+
// Act & Assert
89+
Assert.ThrowsExactly<ArgumentException>(() => PolylineEncoderExtensions.Encode(encoder, coordinates));
9490
}
9591

9692
/// <summary>
@@ -105,7 +101,7 @@ public void Encode_ArrayWithNullEncoder_ThrowsArgumentNullException()
105101
Coordinate[] coordinates = [new Coordinate(38.5, -120.2)];
106102

107103
// Act & Assert
108-
ArgumentNullException exception = Assert.ThrowsExactly<ArgumentNullException>(() => encoder!.Encode(coordinates));
104+
ArgumentNullException exception = Assert.ThrowsExactly<ArgumentNullException>(() => PolylineEncoderExtensions.Encode(encoder!, coordinates));
109105
Assert.AreEqual("encoder", exception.ParamName);
110106
}
111107

@@ -137,13 +133,13 @@ public void Encode_ArrayWithValidEncoder_CallsEncoderWithCoordinatesFromArray()
137133
[
138134
new Coordinate(38.5, -120.2),
139135
new Coordinate(40.7, -120.95),
140-
new Coordinate(43.252, -126.453)
136+
new Coordinate(43.252, -126.453),
141137
];
142138
Polyline expectedPolyline = Polyline.FromString("_p~iF~ps|U_ulLnnqC_mqNvxq`@");
143139
PolylineEncoder encoder = new();
144140

145141
// Act
146-
Polyline result = encoder.Encode(coordinates);
142+
Polyline result = PolylineEncoderExtensions.Encode(encoder, coordinates);
147143

148144
// Assert
149145
Assert.AreEqual(expectedPolyline, result);
@@ -158,13 +154,9 @@ public void Encode_ArrayWithEmptyArray_CallsEncoderWithEmptySpan()
158154
{
159155
// Arrange
160156
Coordinate[] coordinates = [];
161-
Polyline expectedPolyline = Polyline.FromString("");
162157
PolylineEncoder encoder = new();
163158

164-
// Act
165-
Polyline result = encoder.Encode(coordinates);
166-
167-
// Assert
168-
Assert.AreEqual(expectedPolyline, result);
159+
// Act & Assert
160+
Assert.ThrowsExactly<ArgumentException>(() => PolylineEncoderExtensions.Encode(encoder, coordinates));
169161
}
170162
}

0 commit comments

Comments
 (0)