public void CTOR_DDM_Test() { var mvcm = new MontevideoCoordinateModel(); decimal latDegrees = mvcm.DegreesLat; decimal latMins = mvcm.DdmMinsLat; decimal lonDegrees = mvcm.DegreesLon; decimal lonMins = mvcm.DdmMinsLon; var ddm = new DDMCoordinate(latDegrees, latMins, lonDegrees, lonMins); string expectedResult = MontevideoCoordinateModel.StrDDM(); string actualResult = ddm.ToString(); decimal latDiff = Math.Abs(ddm.GetShortDegreesLat() - Math.Truncate(mvcm.DegreesLat)); decimal lonDiff = Math.Abs(ddm.GetShortDegreesLon() - Math.Truncate(mvcm.DegreesLon)); decimal latMinsDiff = Math.Abs(ddm.GetMinsLat() - mvcm.DdmMinsLat); decimal lonMinsDiff = Math.Abs(ddm.GetMinsLon() - mvcm.DdmMinsLon); var dict = new Dictionary <string, decimal> { { "latDiff", latDiff }, { "lonDiff", lonDiff }, { "latMinsDiff", latMinsDiff }, { "lonMinsDiff", lonMinsDiff } }; DisplayOutput(expectedResult, actualResult, dict); Assert.IsTrue(latDiff >= 0 && latDiff <= DegreeAccuracyThreshold); Assert.IsTrue(latMinsDiff >= 0 && latMinsDiff <= LatMinsAccuracyThreshold); Assert.IsTrue(lonDiff >= 0 && lonDiff <= DegreeAccuracyThreshold); Assert.IsTrue(lonMinsDiff >= 0 && lonMinsDiff <= LonMinsAccuracyThreshold); }
public void DmsToDDM_SW_Test() { var mvcm = new MontevideoCoordinateModel(); var ddm = new DDMCoordinate( mvcm.ShortDegreesLattitude(), mvcm.DdmMinsLat, mvcm.DmsSecondsLat, mvcm.ShortDegreesLongitude(), mvcm.DdmMinsLon, mvcm.DmsSecondsLon ); string expectedResult = MontevideoCoordinateModel.StrDDM(); int expectedLength = expectedResult.Length; string actualResult = ddm.ToString(); int actualLength = actualResult.Length; decimal latDiff = Math.Abs(ddm.GetShortDegreesLat() - Math.Truncate(mvcm.DegreesLat)); decimal lonDiff = Math.Abs(ddm.GetShortDegreesLon() - Math.Truncate(mvcm.DegreesLon)); decimal latMinsDiff = Math.Abs(ddm.GetMinsLat() - mvcm.DdmMinsLat); decimal lonMinsDiff = Math.Abs(ddm.GetMinsLon() - mvcm.DdmMinsLon); var dict = new Dictionary <string, decimal> { { "latDiff", latDiff }, { "lonDiff", lonDiff }, { "latMinsDiff", latMinsDiff }, { "lonMinsDiff", lonMinsDiff } }; DisplayOutput(expectedResult, actualResult, dict); Assert.AreEqual(expectedLength, actualLength); Assert.IsTrue(latDiff >= 0 && latDiff <= DegreeAccuracyThreshold); Assert.IsTrue(latMinsDiff >= 0 && latMinsDiff <= LatMinsAccuracyThreshold); Assert.IsTrue(lonDiff >= 0 && lonDiff <= DegreeAccuracyThreshold); Assert.IsTrue(lonMinsDiff >= 0 && lonMinsDiff <= LonMinsAccuracyThreshold); }
public void DdToDDM_NW_Test() { var sccm = new SanClementeCoordinatesModel(); var ddm = new DDMCoordinate( sccm.DegreesLat, sccm.DegreesLon ); string expectedResult = SanClementeCoordinatesModel.StrDDM(); int expectedLength = expectedResult.Length; string actualResult = ddm.ToString(); int actualLength = actualResult.Length; decimal latDiff = Math.Abs(ddm.GetShortDegreesLat() - Math.Truncate(sccm.DegreesLat)); decimal lonDiff = Math.Abs(ddm.GetShortDegreesLon() - Math.Truncate(sccm.DegreesLon)); decimal latMinsDiff = Math.Abs(ddm.GetMinsLat() - sccm.DdmMinsLat); decimal lonMinsDiff = Math.Abs(ddm.GetMinsLon() - sccm.DdmMinsLon); var dict = new Dictionary <string, decimal> { { "latDiff", latDiff }, { "lonDiff", lonDiff }, { "latMinsDiff", latMinsDiff }, { "lonMinsDiff", lonMinsDiff } }; DisplayOutput(expectedResult, actualResult, dict); Assert.AreEqual(expectedLength, actualLength); Assert.IsTrue(latDiff >= 0 && latDiff <= DegreeAccuracyThreshold); Assert.IsTrue(latMinsDiff >= 0 && latMinsDiff <= LatMinsAccuracyThreshold); Assert.IsTrue(lonDiff >= 0 && lonDiff <= DegreeAccuracyThreshold); Assert.IsTrue(lonMinsDiff >= 0 && lonMinsDiff <= LonMinsAccuracyThreshold); }
public void ConvertGridsquareToDDMTestSW() { var cc = new GridDdmExpert(); string gridsquare = WellingtonCoordinateModel.StrGridsquare(); var expectedResult = new DDMCoordinate(WellingtonCoordinateModel.StrAttainableDDM()); DDMCoordinate actualResult = cc.ConvertGridsquareToDDM(gridsquare); decimal latDiff = Math.Abs(expectedResult.GetShortDegreesLat() - actualResult.GetShortDegreesLat()); decimal lonDiff = Math.Abs(expectedResult.GetShortDegreesLon() - actualResult.GetShortDegreesLon()); decimal latMinsDiff = Math.Abs(expectedResult.GetMinsLat() - actualResult.GetMinsLat()); decimal lonMinsDiff = Math.Abs(expectedResult.GetMinsLon() - actualResult.GetMinsLon()); var dict = new Dictionary <string, decimal> { { "latDiff", latDiff }, { "lonDiff", lonDiff }, { "latMinsDiff", latMinsDiff }, { "lonMinsDiff", lonMinsDiff } }; DisplayOutput(expectedResult.ToString(), actualResult.ToString(), dict); Assert.IsTrue(latDiff >= 0 && latDiff <= DegreeAccuracyThreshold); Assert.IsTrue(latMinsDiff >= 0 && latMinsDiff <= LatMinsAccuracyThreshold); Assert.IsTrue(lonDiff >= 0 && lonDiff <= DegreeAccuracyThreshold); Assert.IsTrue(lonMinsDiff >= 0 && lonMinsDiff <= LonMinsAccuracyThreshold); }
public void DefaultCtorCreatesInvalidDMSCoordinate_Test() { var ddm = new DDMCoordinate(); var expectedResult = false; var expectedLatDegrees = 0m; var expectedLatMins = 0m; var expectedLonDegrees = 0m; var expectedLonMins = 0m; var actualResult = ddm.IsValid; var actualLatDegrees = ddm.GetShortDegreesLat(); var actualLatMins = ddm.GetMinsLat(); var actualLonDegrees = ddm.GetShortDegreesLon(); var actualLonMins = ddm.GetMinsLon(); Assert.AreEqual(expectedLatDegrees, actualLatDegrees); Assert.AreEqual(expectedLatMins, actualLatMins); Assert.AreEqual(expectedLonDegrees, actualLonDegrees); Assert.AreEqual(expectedLonMins, actualLonMins); Assert.AreEqual(expectedResult, actualResult); }