Skip to content

Commit 386745b

Browse files
Copilotpetesramek
andauthored
test: consolidate, standardize and improve test suite
- Remove unused Moq package reference - Fix blank lines between [TestMethod] and public void (artifacts of previously removed [TestCategory] attributes) in ExceptionGuardTests, PolylineEncodingTests, CoordinateDeltaTests, Pow10Tests - Consolidate Pow10Tests: 13 individual tests -> 2 data-driven [DataRow] methods - Consolidate CoordinateDeltaTests: 8+ repeated Next/ToString tests -> 3 DataRow methods covering all input combinations - Consolidate PolylineEncodingTests (1424 -> 681 lines): Normalize non-finite, Normalize value, Denormalize value, GetRequiredBufferSize, ValidateCharRange, ValidateBlockLength all converted to [DataRow] - Add XML doc comments to LogDebugExtensionsTests and LogWarningExtensionsTests methods - Rewrite AbstractPolylineDecoderTests: add copyright header, file-scoped namespace, XML docs, explicit types - Add using System.Globalization to CoordinateDeltaTests Agent-Logs-Url: https://github.com/petesramek/polyline-algorithm-csharp/sessions/2ffb0731-b271-46b2-8126-78f2f97d1f21 Co-authored-by: petesramek <2333452+petesramek@users.noreply.github.com>
1 parent 663fa25 commit 386745b

8 files changed

Lines changed: 468 additions & 1473 deletions

File tree

Lines changed: 56 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,59 @@
1+
//
2+
// Copyright © Pete Sramek. All rights reserved.
3+
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace PolylineAlgorithm.Tests.Abstraction;
7+
18
using PolylineAlgorithm.Abstraction;
9+
using System;
10+
using System.Collections.Generic;
11+
12+
/// <summary>
13+
/// Tests for <see cref="AbstractPolylineDecoder{TPolyline, TCoordinate}"/>.
14+
/// </summary>
15+
[TestClass]
16+
public sealed class AbstractPolylineDecoderTests {
17+
private sealed class TestStringDecoder : AbstractPolylineDecoder<string, (double Latitude, double Longitude)> {
18+
protected override ReadOnlyMemory<char> GetReadOnlyMemory(in string polyline) => polyline.AsMemory();
19+
protected override (double Latitude, double Longitude) CreateCoordinate(double latitude, double longitude) => (latitude, longitude);
20+
}
21+
22+
/// <summary>
23+
/// Tests that Decode with a null polyline throws <see cref="ArgumentNullException"/>.
24+
/// </summary>
25+
[TestMethod]
26+
public void Decode_With_Null_Polyline_Throws_ArgumentNullException() {
27+
// Arrange
28+
TestStringDecoder decoder = new();
29+
30+
// Act & Assert
31+
ArgumentNullException ex = Assert.ThrowsExactly<ArgumentNullException>(() => decoder.Decode((string?)null!).ToList());
32+
Assert.AreEqual("polyline", ex.ParamName);
33+
}
34+
35+
/// <summary>
36+
/// Tests that Decode with an empty polyline throws <see cref="InvalidPolylineException"/>.
37+
/// </summary>
38+
[TestMethod]
39+
public void Decode_With_Empty_Polyline_Throws_InvalidPolylineException() {
40+
// Arrange
41+
TestStringDecoder decoder = new();
42+
43+
// Act & Assert
44+
Assert.ThrowsExactly<InvalidPolylineException>(() => decoder.Decode(string.Empty).ToList());
45+
}
46+
47+
/// <summary>
48+
/// Tests that Decode with a polyline containing an invalid character throws <see cref="InvalidPolylineException"/>.
49+
/// </summary>
50+
[TestMethod]
51+
public void Decode_With_Invalid_Character_Polyline_Throws_InvalidPolylineException() {
52+
// Arrange
53+
TestStringDecoder decoder = new();
254

3-
namespace PolylineAlgorithm.Tests.Abstraction {
4-
[TestClass]
5-
public sealed class AbstractPolylineDecoderTests {
6-
private sealed class TestStringDecoder : AbstractPolylineDecoder<string, (double Latitude, double Longitude)> {
7-
protected override ReadOnlyMemory<char> GetReadOnlyMemory(in string polyline) => polyline.AsMemory();
8-
protected override (double Latitude, double Longitude) CreateCoordinate(double latitude, double longitude) => (latitude, longitude);
9-
}
10-
11-
[TestMethod]
12-
public void Decode_Null_Polyline_Throws_ArgumentNullException() {
13-
// Arrange
14-
var decoder = new TestStringDecoder();
15-
16-
// Act & Assert
17-
var ex = Assert.ThrowsExactly<ArgumentNullException>(() => decoder.Decode((string?)null!).ToList());
18-
Assert.AreEqual("polyline", ex.ParamName);
19-
}
20-
21-
[TestMethod]
22-
public void Decode_Empty_Polyline_Throws_InvalidPolylineException() {
23-
// Arrange
24-
var decoder = new TestStringDecoder();
25-
26-
// Act & Assert - empty string is too short (min block length = 1)
27-
Assert.ThrowsExactly<InvalidPolylineException>(() => decoder.Decode(string.Empty).ToList());
28-
}
29-
30-
[TestMethod]
31-
public void Decode_Invalid_Character_Polyline_Throws_InvalidPolylineException() {
32-
// Arrange
33-
var decoder = new TestStringDecoder();
34-
35-
// '!' (33) is below allowed range ('?' == 63) and should trigger invalid polyline character
36-
Assert.ThrowsExactly<InvalidPolylineException>(() => decoder.Decode("!").ToList());
37-
}
55+
// '!' (33) is below allowed range ('?' == 63)
56+
// Act & Assert
57+
Assert.ThrowsExactly<InvalidPolylineException>(() => decoder.Decode("!").ToList());
3858
}
39-
}
59+
}

0 commit comments

Comments
 (0)