public void CTOR_DDMtoDMS_Test() { var lcm = new LynnwoodCoordinatesModel(); var dms = new DMSCoordinate(lcm.ShortDegreesLattitude(), lcm.DdmMinsLat, lcm.ShortDegreesLongitude(), lcm.DdmMinsLon); string expectedResult = LynnwoodCoordinatesModel.StrDMS(); string actualResult = dms.ToString(); if (expectedResult != actualResult) { decimal latDiff = Math.Abs(dms.GetShortDegreesLat() - Math.Truncate(lcm.DegreesLat)); decimal lonDiff = Math.Abs(dms.GetShortDegreesLon() - Math.Truncate(lcm.DegreesLon)); decimal latMinsDiff = Math.Abs(dms.GetShortMinutesLattitude() - Math.Truncate(lcm.DdmMinsLat)); decimal lonMinsDiff = Math.Abs(dms.GetShortMinutesLongitude() - Math.Truncate(lcm.DdmMinsLon)); decimal latSecsDiff = Math.Abs(dms.GetSecondsLattitude() - lcm.DmsSecondsLat); decimal lonSecsDiff = Math.Abs(dms.GetSecondsLongitude() - lcm.DmsSecondsLon); var dict = new Dictionary <string, decimal> { { "latDiff", latDiff }, { "lonDiff", lonDiff }, { "latMinsDiff", latMinsDiff }, { "lonMinsDiff", lonMinsDiff }, { "latSecsDiff", latSecsDiff }, { "lonSecsDiff", lonSecsDiff } }; DisplayOutput(expectedResult, actualResult, dict); Assert.IsTrue(latDiff >= 0 && latDiff <= 0.0001m); Assert.IsTrue(latMinsDiff >= 0 && latMinsDiff <= 0.1m); Assert.IsTrue(latSecsDiff >= 0 && latSecsDiff <= 1.0m); Assert.IsTrue(lonDiff >= 0 && lonDiff <= 0.0001m); Assert.IsTrue(lonMinsDiff >= 0 && lonMinsDiff <= 0.1m); Assert.IsTrue(lonSecsDiff >= 0 && lonSecsDiff <= 1.0m); } else { Assert.AreEqual(expectedResult, actualResult); } }
public void GetNSEW_Test() { string expectedLattitudeResult = "N"; string expectedLongitudeResult = "W"; string expectedCombinedResult = "NW"; string lcm = LynnwoodCoordinatesModel.StrDDM(); string[] splitLatAndLon = lcm.ToString().Split(CommaSymbol); string lcmLattitude = splitLatAndLon[0]; string lcmLongitude = splitLatAndLon[1]; string actualLattitudeResult = ConversionHelper.GetNSEW(lcmLattitude); string actualLongitudeResult = ConversionHelper.GetNSEW(lcmLongitude); string actualCombinedResult = ConversionHelper.GetNSEW(lcm); Assert.AreEqual(expectedLattitudeResult, actualLattitudeResult); Assert.AreEqual(expectedLongitudeResult, actualLongitudeResult); Assert.AreEqual(expectedCombinedResult, actualCombinedResult); }
public void CTOR_DDtoDMS_SW_Test() { var mvcm = new MontevideoCoordinateModel(); decimal ddLat = mvcm.DegreesLat; decimal ddLon = mvcm.DegreesLon; var dms = new DMSCoordinate(ddLat, ddLon); string expectedResult = LynnwoodCoordinatesModel.StrDMS(); string actualResult = dms.ToString(); decimal latDiff = Math.Abs(dms.GetShortDegreesLat() - Math.Truncate(mvcm.DegreesLat)); decimal lonDiff = Math.Abs(dms.GetShortDegreesLon() - Math.Truncate(mvcm.DegreesLon)); decimal latMinsDiff = Math.Abs(dms.GetShortMinutesLattitude() - Math.Truncate(mvcm.DdmMinsLat)); decimal lonMinsDiff = Math.Abs(dms.GetShortMinutesLongitude() - Math.Truncate(mvcm.DdmMinsLon)); decimal latSecsDiff = Math.Abs(dms.GetSecondsLattitude() - mvcm.DmsSecondsLat); decimal lonSecsDiff = Math.Abs(dms.GetSecondsLongitude() - mvcm.DmsSecondsLon); var dict = new Dictionary <string, decimal> { { "latDiff", latDiff }, { "lonDiff", lonDiff }, { "latMinsDiff", latMinsDiff }, { "lonMinsDiff", lonMinsDiff }, { "latSecsDiff", latSecsDiff }, { "lonSecsDiff", lonSecsDiff } }; DisplayOutput(expectedResult, actualResult, dict); Assert.IsTrue(latDiff >= 0 && latDiff <= 0.0001m); Assert.IsTrue(latMinsDiff >= 0 && latMinsDiff <= 0.1m); Assert.IsTrue(latSecsDiff >= 0 && latSecsDiff <= 1.0m); Assert.IsTrue(lonDiff >= 0 && lonDiff <= 0.0001m); Assert.IsTrue(lonMinsDiff >= 0 && lonMinsDiff <= 0.1m); Assert.IsTrue(lonSecsDiff >= 0 && lonSecsDiff <= 1.0m); }