/// <summary> /// Method performs conversion to coordinate tuple and encode operation. /// </summary> /// <param name="source">The <see cref="IEnumerable{T}"/></param> /// <returns>The <see cref="String"/></returns> public string Encode(IEnumerable <T> source) { if (source == null || !source.Any()) { throw new ArgumentException(ExceptionMessageResource.ArgumentCannotBeNullOrEmpty, nameof(source)); } var coordinates = source.Select(s => GetCoordinate(s)); return(PolylineAlgorithm.Encode(coordinates)); }
public void Decode_ValidInput_AreEquivalent() { // Arrange var validPolylineCharArray = Defaults.Polyline.Valid.ToCharArray(); // Act var result = PolylineAlgorithm.Decode(validPolylineCharArray); // Assert CollectionAssert.AreEquivalent(Defaults.Coordinate.Valid.ToList(), result.ToList()); }
public void Encode_ValidInput_AreEqual() { // Arrange var validCoordinates = Defaults.Coordinate.Valid; // Act var result = PolylineAlgorithm.Encode(validCoordinates); // Assert Assert.AreEqual(Defaults.Polyline.Valid, result); }
/// <summary> /// Method performs decode operation and coversion to desired type /// </summary> /// <param name="source">The <see cref="String"/></param> /// <returns>The <see cref="IEnumerable{T}"/></returns> public IEnumerable <T> Decode(string source) { if (String.IsNullOrEmpty(source)) { throw new ArgumentException(ExceptionMessageResource.ArgumentCannotBeNullOrEmpty, nameof(source)); } char[] polyline = source.ToCharArray(); return(PolylineAlgorithm.Decode(polyline) .Select(c => CreateResult(c.Latitude, c.Longitude))); }
public void Decode_NullInput_ThrowsException() { // Arrange var nullPolylineCharArray = (char[])null; // Act void DecodeNullPolylineCharArray() { PolylineAlgorithm.Decode(nullPolylineCharArray); } // Assert Assert.ThrowsException <ArgumentException>(() => DecodeNullPolylineCharArray()); }
public void Decode_InvalidInput_ThrowsException() { // Arrange var invalidPolylineCharrArray = Defaults.Polyline.Invalid.ToCharArray(); // Act void DecodeInvalidPolylineCharArray() { PolylineAlgorithm.Decode(invalidPolylineCharrArray); } // Assert Assert.ThrowsException <InvalidOperationException>(() => DecodeInvalidPolylineCharArray()); }
public void Decode_EmptyInput_ThrowsException() { // Arrange var emptyPolylineCharArray = Defaults.Polyline.Empty.ToCharArray(); // Act void DecodeEmptyPolylineCharArray() { PolylineAlgorithm.Decode(emptyPolylineCharArray); } // Assert Assert.ThrowsException <ArgumentException>(() => DecodeEmptyPolylineCharArray()); }
public void Encode_NullInput_ThrowsException() { // Arrange var nullCoordinates = (IEnumerable <(double, double)>)null; // Act void EncodeNullCoordinates() { PolylineAlgorithm.Encode(nullCoordinates); } // Assert Assert.ThrowsException <ArgumentException>(() => EncodeNullCoordinates()); }
public void Encode_InvalidInput_ThrowsException() { // Arrange var invalidCoordinates = Defaults.Coordinate.Invalid; // Act void EncodeInvalidCoordinates() { PolylineAlgorithm.Encode(invalidCoordinates); } // Assert Assert.ThrowsException <AggregateException>(() => EncodeInvalidCoordinates()); }
public void Encode_EmptyInput_ThrowsException() { // Arrange var emptyCoordinates = Defaults.Coordinate.Empty; // Act void EncodeEmptyCoordinates() { PolylineAlgorithm.Encode(emptyCoordinates); } // Assert Assert.ThrowsException <ArgumentException>(() => EncodeEmptyCoordinates()); }