|
| 1 | +namespace PolylineAlgorithm.Tests; |
| 2 | + |
| 3 | +using PolylineAlgorithm.Extensions; |
| 4 | +using PolylineAlgorithm.Utility; |
| 5 | +using System.Collections.Generic; |
| 6 | +using System.Linq; |
| 7 | + |
| 8 | +[TestClass] |
| 9 | +public class PolylineDecoderExtensionsTest { |
| 10 | + private readonly PolylineDecoder decoder = new PolylineDecoder(); |
| 11 | + |
| 12 | + public static IEnumerable<object[]> CoordinateCount => [[1], [10], [100], [1_000]]; |
| 13 | + |
| 14 | + [TestMethod] |
| 15 | + [DynamicData(nameof(CoordinateCount), DynamicDataSourceType.Property)] |
| 16 | + public void Decode_String_Returns_Expected_Coordinates(int count) { |
| 17 | + // Arrange |
| 18 | + var polyline = RandomValueProvider.GetPolyline(count); |
| 19 | + var expected = RandomValueProvider.GetCoordinates(count) |
| 20 | + .Select(c => new Coordinate(c.Latitude, c.Longitude)) |
| 21 | + .ToList(); |
| 22 | + |
| 23 | + // Act |
| 24 | + var result = PolylineDecoderExtensions.Decode(decoder, polyline).ToList(); |
| 25 | + |
| 26 | + // Assert |
| 27 | + CollectionAssert.AreEqual(expected, result); |
| 28 | + } |
| 29 | + |
| 30 | + [TestMethod] |
| 31 | + [DynamicData(nameof(CoordinateCount), DynamicDataSourceType.Property)] |
| 32 | + public void Decode_CharArray_Returns_Expected_Coordinates(int count) { |
| 33 | + // Arrange |
| 34 | + var polyline = RandomValueProvider.GetPolyline(count).ToCharArray(); |
| 35 | + var expected = RandomValueProvider.GetCoordinates(count) |
| 36 | + .Select(c => new Coordinate(c.Latitude, c.Longitude)) |
| 37 | + .ToList(); |
| 38 | + |
| 39 | + // Act |
| 40 | + var result = PolylineDecoderExtensions.Decode(decoder, polyline).ToList(); |
| 41 | + |
| 42 | + // Assert |
| 43 | + CollectionAssert.AreEqual(expected, result); |
| 44 | + } |
| 45 | + |
| 46 | + [TestMethod] |
| 47 | + [DynamicData(nameof(CoordinateCount), DynamicDataSourceType.Property)] |
| 48 | + public void Decode_Memory_Returns_Expected_Coordinates(int count) { |
| 49 | + // Arrange |
| 50 | + var polyline = RandomValueProvider.GetPolyline(count).AsMemory(); |
| 51 | + var expected = RandomValueProvider.GetCoordinates(count) |
| 52 | + .Select(c => new Coordinate(c.Latitude, c.Longitude)) |
| 53 | + .ToList(); |
| 54 | + |
| 55 | + // Act |
| 56 | + var result = PolylineDecoderExtensions.Decode(decoder, polyline).ToList(); |
| 57 | + |
| 58 | + // Assert |
| 59 | + CollectionAssert.AreEqual(expected, result); |
| 60 | + } |
| 61 | + |
| 62 | +} |
0 commit comments