private static void Load_Call_Tests(Coordinate c) { //Check Load_Calls bool pass = true; c.LoadCelestialInfo(); if (c.CelestialInfo == null) { pass = false; } c.LoadUTM_MGRS_Info(); if (c.UTM == null) { pass = false; } if (c.MGRS == null) { pass = false; } c.LoadCartesianInfo(); if (c.Cartesian == null) { pass = false; } c.LoadECEFInfo(); if (c.ECEF == null) { pass = false; } Pass.Write("Load Calls (Celestial, UTM, MGRS, Cartesian, ECEF)", pass); if (pass) { Celestial cel = c.CelestialInfo; MilitaryGridReferenceSystem mgrs = c.MGRS; UniversalTransverseMercator utm = c.UTM; Cartesian cart = c.Cartesian; ECEF ecef = c.ECEF; c.Latitude.DecimalDegree = -45; c.Longitude.DecimalDegree = -75; //Properties should not change. if (!ReflectiveEquals(c.CelestialInfo, cel)) { pass = false; } if (!ReflectiveEquals(c.MGRS, mgrs)) { pass = false; } if (!ReflectiveEquals(c.UTM, utm)) { pass = false; } if (!ReflectiveEquals(c.Cartesian, cart)) { pass = false; } if (!ReflectiveEquals(c.ECEF, ecef)) { pass = false; } //Properties should remain equal as no load calls were made Pass.Write("Property State Hold (Celestial, UTM, MGRS, Cartesian, ECEF)", pass); //Properties should change pass = true; c.LoadCelestialInfo(); c.LoadCartesianInfo(); c.LoadUTM_MGRS_Info(); c.LoadECEFInfo(); if (ReflectiveEquals(c.CelestialInfo, cel)) { pass = false; } if (ReflectiveEquals(c.MGRS, mgrs)) { pass = false; } if (ReflectiveEquals(c.UTM, utm)) { pass = false; } if (ReflectiveEquals(c.Cartesian, cart)) { pass = false; } if (ReflectiveEquals(c.ECEF, ecef)) { pass = false; } //Properties should not be equal as chages have been made Pass.Write("Property State Change (Celestial, UTM, MGRS, Cartesian, ECEF)", pass); } else { //Passes auto fail has properties didn't load when called. Pass.Write("Property State Hold (Celestial, UTM, MGRS, Cartesian, ECEF)", false); Pass.Write("Property State Change (Celestial, UTM, MGRS, Cartesian, ECEF)", false); } }
public static void Run_Test() { Console.WriteLine("Loading Celestial Values..."); Console.WriteLine(); CelestialTests ct = new CelestialTests(); ct.Populate_CelestialTests(); Coordinate c = new Coordinate(); Pass.Write("Sunset: ", ct.Check_Values(ct.SunSets, "CelestialData\\SunSet.txt")); Pass.Write("Sunrise: ", ct.Check_Values(ct.SunRises, "CelestialData\\SunRise.txt")); Pass.Write("AstroDawn: ", ct.Check_Values(ct.AstroDawn, "CelestialData\\AstroDawn.txt")); Pass.Write("AstroDusk: ", ct.Check_Values(ct.AstroDusk, "CelestialData\\AstroDusk.txt")); Pass.Write("CivilDawn: ", ct.Check_Values(ct.CivilDawn, "CelestialData\\CivilDawn.txt")); Pass.Write("CivilDusk: ", ct.Check_Values(ct.CivilDusk, "CelestialData\\CivilDusk.txt")); Pass.Write("NauticalDawn: ", ct.Check_Values(ct.NauticalDawn, "CelestialData\\NauticalDawn.txt")); Pass.Write("NauticalDusk: ", ct.Check_Values(ct.NauticalDusk, "CelestialData\\NauticalDusk.txt")); Pass.Write("BottomSolarDiscRise: ", ct.Check_Values(ct.BottomSolarDiscRise, "CelestialData\\BottomDiscRise.txt")); Pass.Write("BottomSolarDiscSet: ", ct.Check_Values(ct.BottomSolarDiscSet, "CelestialData\\BottomDiscSet.txt")); Pass.Write("Moon Set: ", ct.Check_Values(ct.MoonSets, "CelestialData\\MoonSet.txt")); Pass.Write("Moon Rise: ", ct.Check_Values(ct.MoonRises, "CelestialData\\MoonRise.txt")); Console.WriteLine(); Pass.Write("Sun Altitude: ", ct.Check_Values(ct.SunAlts, "CelestialData\\SunAlts.txt")); Pass.Write("Sun Azimuth: ", ct.Check_Values(ct.SunAzs, "CelestialData\\SunAzs.txt")); Pass.Write("Moon Altitude: ", ct.Check_Values(ct.MoonAlts, "CelestialData\\MoonAlts.txt")); Pass.Write("Moon Azimuth: ", ct.Check_Values(ct.MoonAzs, "CelestialData\\MoonAzs.txt")); Pass.Write("Moon Distance: ", ct.Check_Values(ct.MoonDistances, "CelestialData\\MoonDistance.txt")); Pass.Write("Moon Fraction: ", ct.Check_Values(ct.MoonFraction, "CelestialData\\MoonFraction.txt")); Pass.Write("Moon Phase ", ct.Check_Values(ct.MoonPhase, "CelestialData\\MoonPhase.txt")); Pass.Write("Moon Phase Name: ", ct.Check_Values(ct.MoonPhaseName, "CelestialData\\MoonPhaseName.txt")); Console.WriteLine(); Pass.Write("Solar Eclipse: ", ct.Check_Solar_Eclipse()); Pass.Write("Lunar Eclipse: ", ct.Check_Lunar_Eclipse()); Pass.Write("Perigee: ", ct.Check_Perigee()); Pass.Write("Apogee: ", ct.Check_Apogee()); Console.WriteLine(); Pass.Write("Local Time Conversions", ct.Check_Local_Times()); Console.WriteLine(); Pass.Write("Static_Last_Next_Rise_Set_Checks", ct.Check_Static_Last_Next_Times()); Console.WriteLine(); while (true) { Console.ForegroundColor = ConsoleColor.DarkYellow; Console.WriteLine("Base celestial tests are completed. Do you wish to run additional \"IsUp\" tests? (Y/N)..."); ConsoleKeyInfo key = Console.ReadKey(); Console.ForegroundColor = ConsoleColor.White; if (key.Key == ConsoleKey.Y) { break; } if (key.Key == ConsoleKey.N) { return; } Console.WriteLine(); Console.WriteLine("INVALID CHOICE!"); Console.WriteLine(); } Console.WriteLine(); Console.WriteLine("***Running IsSunUp Test (This will take a minute)****"); Console.WriteLine(); Pass.Write("IsSunUp", ct.Check_IsSunUp()); Console.WriteLine(); Console.WriteLine("***Running IsMoonUp Test (This will take a minute)****"); Console.WriteLine(); Pass.Write("IsMoonUp", ct.Check_IsMoonUp()); Console.WriteLine(); }
private static void Extensions_Test() { EagerLoad e = new EagerLoad(false); Coordinate c = new Coordinate(45, 75, new DateTime(2008, 1, 2), e); Celestial cel = c.CelestialInfo; c.Latitude.DecimalDegree = -44; //Trigger Calculations bool pass = true; if (!ReflectiveEquals(c.CelestialInfo, cel)) { pass = false; } c.EagerLoadSettings.Celestial = true; c.EagerLoadSettings.Extensions = new EagerLoad_Extensions(false); //All Extensions Off cel = c.CelestialInfo; c.Latitude.DecimalDegree++; //EagerLoading was turned on but exentsions were turned off //CelestialInfo should no longer be null but, properties will still be empty if (c.CelestialInfo == null || c.CelestialInfo.SunSet != null) { pass = false; } if (c.CelestialInfo == null) { pass = false; } var sunset = c.CelestialInfo.SunSet; var moonset = c.CelestialInfo.MoonSet; var sEclipse = c.CelestialInfo.SolarEclipse.LastEclipse.MaximumEclipse; var lEclipse = c.CelestialInfo.LunarEclipse.LastEclipse.PenumbralEclipseBegin; var moonZodiac = c.CelestialInfo.AstrologicalSigns.MoonSign; var sunZodiac = c.CelestialInfo.AstrologicalSigns.ZodiacSign; var moonName = c.CelestialInfo.AstrologicalSigns.MoonName; //The following test will test each extension individually. //The Eager Loaded extension property should change while all others should not. c.EagerLoadSettings.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Solar_Cycle); c.Latitude.DecimalDegree++; if (c.CelestialInfo.SunSet == sunset) { pass = false; } sunset = c.CelestialInfo.SunSet; c.EagerLoadSettings.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Lunar_Cycle); c.Latitude.DecimalDegree++; if (c.CelestialInfo.MoonSet == moonset || sunset != c.CelestialInfo.SunSet) { pass = false; } moonset = c.CelestialInfo.MoonSet; c.EagerLoadSettings.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Solar_Eclipse); c.Latitude.DecimalDegree *= -1; if (c.CelestialInfo.SolarEclipse.LastEclipse.MaximumEclipse == sEclipse || moonset != c.CelestialInfo.MoonSet) { pass = false; } sEclipse = c.CelestialInfo.SolarEclipse.LastEclipse.MaximumEclipse; c.EagerLoadSettings.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Lunar_Eclipse); c.Latitude.DecimalDegree++; if (c.CelestialInfo.LunarEclipse.LastEclipse.PenumbralEclipseBegin == lEclipse || sEclipse != c.CelestialInfo.SolarEclipse.LastEclipse.MaximumEclipse) { pass = false; } lEclipse = c.CelestialInfo.LunarEclipse.LastEclipse.PenumbralEclipseBegin; //Check both moon and sun signs and names! c.EagerLoadSettings.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Zodiac); c.GeoDate = c.GeoDate.AddDays(15); if (c.CelestialInfo.AstrologicalSigns.MoonName == moonName || c.CelestialInfo.AstrologicalSigns.MoonSign == moonZodiac || c.CelestialInfo.AstrologicalSigns.ZodiacSign == sunZodiac || lEclipse != c.CelestialInfo.LunarEclipse.LastEclipse.PenumbralEclipseBegin) { pass = false; } moonName = c.CelestialInfo.AstrologicalSigns.MoonName; sunZodiac = c.CelestialInfo.AstrologicalSigns.ZodiacSign; moonZodiac = c.CelestialInfo.AstrologicalSigns.MoonSign; c.EagerLoadSettings.UTM_MGRS = true; c.EagerLoadSettings.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.MGRS); c.Latitude.DecimalDegree++; if (c.MGRS == null || c.CelestialInfo.AstrologicalSigns.MoonName != moonName || c.CelestialInfo.AstrologicalSigns.MoonSign != moonZodiac || c.CelestialInfo.AstrologicalSigns.ZodiacSign != sunZodiac) { pass = false; } EagerLoad el = new EagerLoad(EagerLoadType.Celestial); el.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Solar_Cycle); c = new Coordinate(45, 45, DateTime.Now, el); if (!Extensions_Null(c.CelestialInfo, EagerLoad_ExtensionsType.Solar_Cycle)) { pass = false; } el.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Lunar_Cycle); c = new Coordinate(45, 45, DateTime.Now, el); if (!Extensions_Null(c.CelestialInfo, EagerLoad_ExtensionsType.Lunar_Cycle)) { pass = false; } el.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Solar_Eclipse); c = new Coordinate(45, 45, DateTime.Now, el); if (!Extensions_Null(c.CelestialInfo, EagerLoad_ExtensionsType.Solar_Eclipse)) { pass = false; } el.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Lunar_Eclipse); c = new Coordinate(45, 45, DateTime.Now, el); if (!Extensions_Null(c.CelestialInfo, EagerLoad_ExtensionsType.Lunar_Eclipse)) { pass = false; } el.Extensions = new EagerLoad_Extensions(EagerLoad_ExtensionsType.Zodiac); c = new Coordinate(45, 45, DateTime.Now, el); if (!Extensions_Null(c.CelestialInfo, EagerLoad_ExtensionsType.Zodiac)) { pass = false; } Pass.Write("Extensions Tests (EagerLoad Extensions)", pass); }
private static void Flags_Test() { EagerLoad eg = new EagerLoad(EagerLoadType.Cartesian | EagerLoadType.Celestial | EagerLoadType.UTM_MGRS | EagerLoadType.ECEF); bool pass = true; if (eg.Cartesian == false || eg.Celestial == false || eg.UTM_MGRS == false || eg.ECEF == false) { pass = false; } eg = new EagerLoad(EagerLoadType.Celestial); if (eg.Cartesian == true || eg.Celestial == false || eg.UTM_MGRS == true || eg.ECEF == true) { pass = false; } eg = new EagerLoad(EagerLoadType.Cartesian); if (eg.Cartesian == false || eg.Celestial == true || eg.UTM_MGRS == true || eg.ECEF == true) { pass = false; } eg = new EagerLoad(EagerLoadType.UTM_MGRS); if (eg.Cartesian == true || eg.Celestial == true || eg.UTM_MGRS == false || eg.ECEF == true) { pass = false; } eg = new EagerLoad(EagerLoadType.ECEF); if (eg.Cartesian == true || eg.Celestial == true || eg.UTM_MGRS == true || eg.ECEF == false) { pass = false; } eg = new EagerLoad(EagerLoadType.UTM_MGRS | EagerLoadType.Celestial); if (eg.Cartesian == true || eg.Celestial == false || eg.UTM_MGRS == false || eg.ECEF == true) { pass = false; } eg = new EagerLoad(EagerLoadType.Cartesian | EagerLoadType.Celestial); if (eg.Cartesian == false || eg.Celestial == false || eg.UTM_MGRS == true || eg.ECEF == true) { pass = false; } eg = new EagerLoad(EagerLoadType.UTM_MGRS | EagerLoadType.Cartesian); if (eg.Cartesian == false || eg.Celestial == true || eg.UTM_MGRS == false || eg.ECEF == true) { pass = false; } eg = new EagerLoad(EagerLoadType.ECEF | EagerLoadType.Celestial); if (eg.Cartesian == true || eg.Celestial == false || eg.UTM_MGRS == true || eg.ECEF == false) { pass = false; } eg = new EagerLoad(EagerLoadType.ECEF | EagerLoadType.Cartesian); if (eg.Cartesian == false || eg.Celestial == true || eg.UTM_MGRS == true || eg.ECEF == false) { pass = false; } eg = new EagerLoad(EagerLoadType.ECEF | EagerLoadType.Cartesian | EagerLoadType.UTM_MGRS); if (eg.Cartesian == false || eg.Celestial == true || eg.UTM_MGRS == false || eg.ECEF == false) { pass = false; } Pass.Write("Flags Test", pass); }
private static void CoordinatePart_Init_Range_Checks() { bool pass = true; try { Coordinate c = new Coordinate(); CoordinatePart cp = new CoordinatePart(90, CoordinateType.Lat); cp = new CoordinatePart(-90, CoordinateType.Lat); cp = new CoordinatePart(89, 59, CoordinatesPosition.N); cp = new CoordinatePart(89, 59, CoordinatesPosition.S); cp = new CoordinatePart(89, 59, 59, CoordinatesPosition.N); cp = new CoordinatePart(89, 59, 59, CoordinatesPosition.S); cp = new CoordinatePart(180, CoordinateType.Long); cp = new CoordinatePart(-180, CoordinateType.Long); cp = new CoordinatePart(179, 59, CoordinatesPosition.E); cp = new CoordinatePart(179, 59, CoordinatesPosition.W); cp = new CoordinatePart(179, 59, 59, CoordinatesPosition.E); cp = new CoordinatePart(179, 59, 59, CoordinatesPosition.W); //Should fail try { cp = new CoordinatePart(91, CoordinateType.Lat); pass = false; } catch { } try { cp = new CoordinatePart(-91, CoordinateType.Lat); pass = false; } catch { } try { cp = new CoordinatePart(181, CoordinateType.Long); pass = false; } catch { } try { cp = new CoordinatePart(-181, CoordinateType.Long); pass = false; } catch { } try { cp = new CoordinatePart(91, 0, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(90, 1, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(89, 60, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(91, 0, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(90, 1, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(89, 60, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(-90, 1, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(89, -1, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(91, 0, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(90, 1, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(89, 60, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(91, 0, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(90, 1, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(89, 60, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(-90, 1, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(89, -1, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(91, 0, 0, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(90, 0, 1, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(89, 59, 60, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(90, 0, 1, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(89, 59, 60, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(-90, 0, 0, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(89, -1, 0, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(89, 1, -1, CoordinatesPosition.N); pass = false; } catch { } try { cp = new CoordinatePart(91, 0, 0, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(90, 0, 1, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(89, 59, 60, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(90, 0, 1, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(89, 59, 60, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(-90, 0, 0, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(89, -1, 0, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(89, 1, -1, CoordinatesPosition.S); pass = false; } catch { } try { cp = new CoordinatePart(181, 0, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(180, 1, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(179, 60, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(181, 0, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(180, 1, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(179, 60, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(-180, 1, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(179, -1, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(181, 0, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(180, 1, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(179, 60, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(181, 0, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(180, 1, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(179, 60, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(-180, 1, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(179, -1, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(181, 0, 0, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(180, 0, 1, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(179, 59, 60, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(180, 0, 1, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(179, 59, 60, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(-180, 0, 0, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(179, -1, 0, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(179, 1, -1, CoordinatesPosition.E); pass = false; } catch { } try { cp = new CoordinatePart(181, 0, 0, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(180, 0, 1, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(179, 59, 60, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(180, 0, 1, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(179, 59, 60, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(-180, 0, 0, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(179, -1, 0, CoordinatesPosition.W); pass = false; } catch { } try { cp = new CoordinatePart(179, 1, -1, CoordinatesPosition.W); pass = false; } catch { } } catch { pass = false; } Pass.Write("CoordinatePart Initialization Range Checks", pass); }
private static void Coordinate_Parses_Test() { Coordinate coordinate; //Parse Coordinate Formats string[] coordStrings = File.ReadAllLines("CoordinateData\\Coordinates.txt"); bool pass = true; string lastType = ""; Console.WriteLine("Coordinate Parses..."); foreach (string c in coordStrings) { if (c.Contains("\\")) { if (lastType != "") { Pass.Write(lastType, pass); } lastType = ""; pass = true; lastType = c; } else { string[] cc = c.Split('#'); if (!Coordinate.TryParse(cc[0], out coordinate)) { pass = false; } else { //CHECK STRING COMPARISON, BUT REPLACE , and . with * to avoid cultural mismatch if (coordinate.ToString().Replace(",", "*").Replace(".", "*") != cc[1].Replace(",", "*").Replace(".", "*")) { Debug.WriteLine("...MISMATCH: " + coordinate.ToString() + " - " + cc[1]); pass = false; } } } } if (lastType != "") { Pass.Write(lastType.Split(',')[0], pass); } //Attempt Forces Param pass = true; try { if (Coordinate.TryParse("95F, 54", out coordinate)) { pass = false; } //Intentional Fail if (Coordinate.TryParse("E 181 30, 56 76", out coordinate)) { pass = false; } //Intentional Fail if (Coordinate.TryParse("N 95 45, E 45", out coordinate)) { pass = false; } //Intentional Fail if (Coordinate.TryParse("95 87 46 78 D", out coordinate)) { pass = false; } //Intentional Fail if (Coordinate.TryParse("W24 45, W45", out coordinate)) { pass = false; } //Intentional Fail } catch { pass = false; } Console.WriteLine(); Pass.Write("\\\\Intentional Fails", pass); Console.WriteLine(); }
private static void CoordinatePart_Parses_Test() { //Parse CoordinatePart Formats Console.WriteLine("CoordinatePart Parses..."); string[] coordStrings = File.ReadAllLines("CoordinateData\\CoordinateParts.txt"); CoordinatePart cp; bool pass = true; string lastType = ""; foreach (string c in coordStrings) { c.Trim(); if (c.Contains("\\")) { if (lastType != "") { Pass.Write(lastType.Split('#')[0], pass); } lastType = ""; pass = true; lastType = c; } else { string[] cc = c.Split('#'); if (!CoordinatePart.TryParse(cc[0], out cp)) { pass = false; } else { if (cp.ToString().Replace(",", "*").Replace(".", "*") != cc[1].Replace(",", "*").Replace(".", "*")) { Debug.WriteLine("...MISMATCH: " + cp.ToString() + " - " + cc[1]); pass = false; } } } } if (lastType != "") { Pass.Write(lastType.Split(',')[0], pass); } //Attempt Forces Param pass = true; try { if (CoordinatePart.TryParse("95", CoordinateType.Lat, out cp)) { pass = false; } //Intentional Fail if (CoordinatePart.TryParse("E181", CoordinateType.Lat, out cp)) { pass = false; } //Intentional Fail if (CoordinatePart.TryParse("N 95 45", CoordinateType.Lat, out cp)) { pass = false; } //Intentional Fail if (CoordinatePart.TryParse("95", CoordinateType.Lat, out cp)) { pass = false; } //Intentional Fail if (CoordinatePart.TryParse("WD24 45", CoordinateType.Lat, out cp)) { pass = false; } //Intentional Fail } catch { pass = false; } Console.WriteLine(); Pass.Write("\\\\Intentional Fails", pass); }