public void BackwardCodeTest()
 {
     var myOpenLocationCode = "9F2P2CQH+WWH";
     var codeVNext = new ASOL.OpenLocationCode.OpenLocationCode(myOpenLocationCode, ASOL.OpenLocationCode.FormatVersion.VNext);
     var codeV1 = codeVNext.ConvertToFormatVersion(ASOL.OpenLocationCode.FormatVersion.V1);
     Console.WriteLine("Code V1> " + codeV1.Code);
     Console.WriteLine("Code VNext> " + codeVNext.Code);
 }
 public void IsShortVNext1Test()
 {
     foreach (var validData in TestDataVNextList)
     {
         var olc = new ASOL.OpenLocationCode.OpenLocationCode(validData.Code, ASOL.OpenLocationCode.FormatVersion.VNext);
         Assert.AreEqual(validData.IsShort, olc.IsShort, validData.Code);
     }
 }
 public void IsShortV1Test()
 {
     foreach (var validData in TestDataV1List)
     {
         var olc = new ASOL.OpenLocationCode.OpenLocationCode(validData.Code);
         Assert.AreEqual(validData.IsShort, olc.IsShort, validData.Code);
     }
 }
 public void ForwardTest()
 {
     var longitude = 14.4298583m;
     var latitude = 50.0398061m;
     var codeV1 = new ASOL.OpenLocationCode.OpenLocationCode(latitude, longitude, ASOL.OpenLocationCode.FormatVersion.V1);
     var codeVNext = codeV1.ConvertToFormatVersion(ASOL.OpenLocationCode.FormatVersion.VNext);
     Assert.AreEqual(codeV1.Longitude, codeVNext.Longitude, "longitude");
     Assert.AreEqual(codeV1.Latitude, codeVNext.Latitude, "latitude");
     Assert.AreNotEqual(codeV1.Code, codeVNext.Code, "code");
 }
        public void V1EncodingDecodingTest()
        {
            foreach (var testFields in TestDataV1List)
            {
                var olcFromCode = new ASOL.OpenLocationCode.OpenLocationCode(testFields.Code);
                var codeArea = olcFromCode.Area;
                var olcFromCoors = new ASOL.OpenLocationCode.OpenLocationCode(testFields.Lat, testFields.Lng, codeArea.CodeLength);
                var code = olcFromCoors.Code;

                // Did we get the same code?
                Assert.AreEqual(testFields.Code, code, testFields.Code + ": decode/encode fail");
                // Check that it decoded to the correct coordinates.
                Assert.AreEqual(testFields.LatLo, codeArea.LatitudeLow, codeArea.LatitudeLow + " latitude Lo fail");
                Assert.AreEqual(testFields.LngLo, codeArea.LongitudeLow, codeArea.LongitudeLow + " longitude Lo fail");
                Assert.AreEqual(testFields.LatHi, codeArea.LatitudeHigh, codeArea.LatitudeHigh + " latitude Hi fail");
                Assert.AreEqual(testFields.LngHi, codeArea.LongitudeHigh, codeArea.LongitudeHigh + " longitude Hi fail");
            }
        }
        public void V1ShortFullTest()
        {
            foreach (var testFields in TestDataV1List)
            {
                var olc = new ASOL.OpenLocationCode.OpenLocationCode(testFields.FullCode);
                // Shorten the code.
                var shortenBy4 = olc.ShortenBy4(testFields.Lat, testFields.Lng);
                var shortenBy6 = olc.ShortenBy6(testFields.Lat, testFields.Lng);

                // Confirm we got what we expected.
                var coords = " with " + testFields.Lat + "," + testFields.Lng;
                Assert.AreEqual(testFields.Trim4, shortenBy4.Code, testFields.FullCode + " shortenBy4 " + coords);

                Assert.AreEqual(testFields.Trim6, shortenBy6.Code, testFields.FullCode + " shortenBy6 " + coords);

                // Now try expanding the shortened code.
                var expanded = shortenBy4.RecoverNearest(testFields.Lat, testFields.Lng).Code;
                Assert.AreEqual(testFields.FullCode, expanded, testFields.FullCode + " expanding shortenBy4 " + coords);

                expanded = shortenBy6.RecoverNearest(testFields.Lat, testFields.Lng).Code;
                Assert.AreEqual(testFields.FullCode, expanded, testFields.FullCode + " expanding shortenBy6 " + coords);
            }
        }
 public void ForwardCodeTest()
 {
     var myOpenLocationCode = "+9F2P.2CQHWWH";
     var codeV1 = new ASOL.OpenLocationCode.OpenLocationCode(myOpenLocationCode, ASOL.OpenLocationCode.FormatVersion.V1);
     var codeVNext = codeV1.ConvertToFormatVersion(ASOL.OpenLocationCode.FormatVersion.VNext);
 }
        public void VNextShortFullTest()
        {
            foreach (var testFields in TestDataVNextList)
            {
                var olc = new ASOL.OpenLocationCode.OpenLocationCode(testFields.FullCode, ASOL.OpenLocationCode.FormatVersion.VNext);
                // Shorten the code.
                var shorten = olc.Shorten(testFields.Lat, testFields.Lng);

                // Confirm we got what we expected.
                var coords = " with " + testFields.Lat + "," + testFields.Lng;
                Assert.AreEqual(testFields.Shortcode, shorten.Code, testFields.FullCode + " shorten " + coords);

                // Now try expanding the shortened code.
                var expanded = shorten.RecoverNearest(testFields.Lat, testFields.Lng).Code;
                Assert.AreEqual(testFields.FullCode, expanded, testFields.FullCode + " expanding shorten " + coords);
            }
        }