Skip to content

Commit 8a1e956

Browse files
committed
refactored static value provider
1 parent 64fa199 commit 8a1e956

3 files changed

Lines changed: 34 additions & 26 deletions

File tree

tests/PolylineAlgorithm.Tests/PolylineDecoderTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ public void Random_Value_Decode_Valid_Input_Ok(int count) {
7171
[TestMethod]
7272
public void Static_Value_Decode_Valid_Input_Ok() {
7373
// Arrange
74-
IEnumerable<Coordinate> expected = StaticValueProvider.GetCoordinates().Select(c => new Coordinate(c.Latitude, c.Longitude));
75-
string value = StaticValueProvider.GetPolyline();
74+
IEnumerable<Coordinate> expected = StaticValueProvider.Valid.GetCoordinates().Select(c => new Coordinate(c.Latitude, c.Longitude));
75+
string value = StaticValueProvider.Valid.GetPolyline();
7676

7777
// Act
7878
var result = Decoder.Decode(Polyline.FromString(value));

tests/PolylineAlgorithm.Tests/PolylineEncoderTest.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public void Encode_RandomValue_ValidInput_Ok(int count) {
7878
[TestMethod]
7979
public void Encode_StaticValue_ValidInput_Ok() {
8080
// Arrange
81-
IEnumerable<Coordinate> valid = StaticValueProvider.GetCoordinates().Select(c => new Coordinate(c.Latitude, c.Longitude));
82-
Polyline expected = Polyline.FromString(StaticValueProvider.GetPolyline());
81+
IEnumerable<Coordinate> valid = StaticValueProvider.Valid.GetCoordinates().Select(c => new Coordinate(c.Latitude, c.Longitude));
82+
Polyline expected = Polyline.FromString(StaticValueProvider.Valid.GetPolyline());
8383

8484
// Act
8585
var result = Encoder.Encode(valid);

utilities/PolylineAlgorithm.Utility/StaticValueProvider.cs

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,38 +11,46 @@ namespace PolylineAlgorithm.Utility;
1111
/// Provides static, predefined coordinate and polyline values for use in tests and benchmarks.
1212
/// </summary>
1313
internal static class StaticValueProvider {
14-
/// <summary>
15-
/// A predefined polyline instance representing a fixed encoded polyline string.
16-
/// </summary>
17-
private static readonly string _polyline = "???_gsia@_cidP??~fsia@?~fsia@~bidP?~bidP??_gsia@";
14+
internal static class Valid {
15+
/// <summary>
16+
/// A predefined polyline instance representing a fixed encoded polyline string.
17+
/// </summary>
18+
private static readonly string _polyline = "???_gsia@_cidP??~fsia@?~fsia@~bidP?~bidP??_gsia@";
1819

19-
/// <summary>
20-
/// A predefined collection of <see cref="Coordinate"/> instances representing a closed path around the globe.
21-
/// </summary>
22-
private static readonly IEnumerable<(double Latitude, double Longitude)> _coordinates = [
23-
new (0, 0),
20+
/// <summary>
21+
/// A predefined collection of <see cref="Coordinate"/> instances representing a closed path around the globe.
22+
/// </summary>
23+
private static readonly IEnumerable<(double Latitude, double Longitude)> _coordinates = [
24+
new (0, 0),
2425
new (0, 180),
2526
new (90, 180),
2627
new (90, 0),
2728
new (90, -180),
2829
new (0, -180),
2930
new (-90, -180),
3031
new (-90, 0)
31-
];
32+
];
3233

33-
/// <summary>
34-
/// Gets the predefined collection of <see cref="Coordinate"/> instances.
35-
/// </summary>
36-
/// <returns>An <see cref="IEnumerable{Coordinate}"/> containing the static coordinates.</returns>
37-
public static IEnumerable<(double Latitude, double Longitude)> GetCoordinates() {
38-
return _coordinates;
34+
/// <summary>
35+
/// Gets the predefined collection of <see cref="Coordinate"/> instances.
36+
/// </summary>
37+
/// <returns>An <see cref="IEnumerable{Coordinate}"/> containing the static coordinates.</returns>
38+
public static IEnumerable<(double Latitude, double Longitude)> GetCoordinates() {
39+
return _coordinates;
40+
}
41+
42+
/// <summary>
43+
/// Gets the predefined <see cref="Polyline"/> instance.
44+
/// </summary>
45+
/// <returns>The static <see cref="Polyline"/> value.</returns>
46+
public static string GetPolyline() {
47+
return _polyline;
48+
}
3949
}
4050

41-
/// <summary>
42-
/// Gets the predefined <see cref="Polyline"/> instance.
43-
/// </summary>
44-
/// <returns>The static <see cref="Polyline"/> value.</returns>
45-
public static string GetPolyline() {
46-
return _polyline;
51+
internal static class Invalid {
52+
//public static string GetMalformedPolyline() {
53+
// return ((char)(127)).ToString();
54+
//}
4755
}
4856
}

0 commit comments

Comments
 (0)