Skip to content

Commit

Permalink
unit tests geofence.csv
Browse files Browse the repository at this point in the history
  • Loading branch information
bassmaster187 committed Feb 10, 2024
1 parent 1955832 commit 0f02b0d
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
4 changes: 2 additions & 2 deletions TeslaLogger/bin/geofence.csv
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ Supercharger NO-Dombås, 62.074749, 9.12783
Supercharger NO-Eidfjord, 60.467438, 7.068209
Supercharger NO-Eidsvoll Verk, 60.312269, 11.145104
Supercharger NO-Elverum old, 60.884053, 11.541698, 20
Supercharger-V3 Elverum, 60.887617,11.515327
Supercharger-V3 NO-Elverum, 60.887617,11.515327
Supercharger-V3 NO-Fauske, 67.258778,15.400971, 20
Supercharger NO-Flå, 60.381236, 9.610003
Supercharger NO-Gol, 60.70232, 8.9862
Expand Down Expand Up @@ -5891,7 +5891,7 @@ Fastned NL-Vliedberg, 51.484310, 3.850840
Fastned NL-Vrijenban, 51.983412, 4.392855
Fastned NL-Wellerzand, 52.784360, 5.759275
Fastned NL-Willemsbos, 52.360573, 5.766818
Fastned-NL Swentibold, 51.010590, 5.800570
Fastned NL-Swentibold, 51.010590, 5.800570

Familia DE-Hamburg, 53.608366, 10.044162
Familia DE-Osterholz-Scharmbeck, 53.232695, 8.754733
Expand Down
44 changes: 43 additions & 1 deletion UnitTestsTeslalogger/UnitTestsGeocode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,50 @@ public void ParseGeocodeFile()
if (name.Contains("\""))
Assert.Fail($"'${name}' contains illegal characters: \"");

if (name.IndexOf("supercharger", StringComparison.OrdinalIgnoreCase) >= 0)
{
if (!name.StartsWith("Supercharger"))
Assert.Fail($"'${name}' must start with Supercharger");

var s = name.Split(' ');
if (s[0] == "Supercharger-V3" || s[0] == "Supercharger-V4" || s[0] == "Supercharger")
{
CheckCountry(s[1], name);
}
else
{
Assert.Fail("Supercharger must start with 'Supercharger', 'Supercherger-V3' or 'Supercharger-V4' : " + name);
}
}
else if (name.StartsWith("Tesla Service Center"))
{
CheckCountry(name.Substring(21), name);
}
else if (name.StartsWith("Circle K"))
{
CheckCountry(name.Substring(9), name);
}
else if (name.StartsWith("Grønn Kontakt"))
{
CheckCountry(name.Substring(14), name);
}
else if (name.Substring(2,1) == " ")
{
// Unspecific Charger starting with country code
}
else
{
CheckCountry(name.Substring(name.IndexOf(" ")+1), name);
}
}
}
}
}

private static void CheckCountry(string name, string fullname)
{
var l = name.Split('-');
if (l[0].Length != 2)
Assert.Fail($"Country ({l}) should be 2 chars: " + fullname);
}
}
}

0 comments on commit 0f02b0d

Please sign in to comment.