Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Commit

Permalink
Added a unit test for Distance.BetweenPositions method
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmanke committed Sep 27, 2019
1 parent 26decfa commit 0678169
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Xamarin.Forms.Core.UnitTests/DistanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ public void ConstructFromMiles()
Assert.True(Math.Abs(distance.Kilometers - 6378.09999805) < EPSILON_FOR_LARGE_MILES_TO_KM);
}

[Test]
public void ConstructFromPositions()
{
const double EPSILON = 0.001;

Position position1 = new Position(37.403992, -122.034988);
Position position2 = new Position(37.776691, -122.416534);

Distance distance = Distance.BetweenPositions(position1, position2);

Assert.True(Math.Abs(distance.Meters - 53363.08) < EPSILON);
Assert.True(Math.Abs(distance.Kilometers - 53.36308) < EPSILON);
Assert.True(Math.Abs(distance.Miles - 33.15828) < EPSILON);
}

[Test]
public void EqualityOp([Range(5, 9)] double x, [Range(5, 9)] double y)
{
Expand Down

0 comments on commit 0678169

Please sign in to comment.