/// <summary> /// Splits Coordinate test string to get value to parse and expected output. /// Checks proper parsing and value /// </summary> /// <param name="val">Test string value</param> private void Parse_Check(string val) { var vals = val.Split('#'); //First part of string is value to parse, seconds is expected string value after parse string coordString = vals[0]; string expected = vals[1]; CoordinatePart c = CoordinatePart.Parse(coordString);//Will throw exception and fail if incorrect (intended behavior) //CHECK STRING COMPARISON, BUT REPLACE , and . with * to avoid cultural mismatch Assert.AreEqual(expected.Replace(",", "*").Replace(".", "*"), c.ToString().Replace(",", "*").Replace(".", "*"), $"{vals} parsed as {c.ToString().Replace(",", "*").Replace(".", "*")} but {expected.Replace(",", "*").Replace(".", "*")} was expected."); }
public void Coordinate_Roundtrippable_Test() { CoordinatePart lat = new CoordinatePart(-0, -0, -0, CoordinatesPosition.N); Assert.AreEqual("N 0º 0' 0\"", lat.ToString(), "Latitude not expected"); CoordinatePart lng = new CoordinatePart(-0, -0, -0, CoordinatesPosition.E); Assert.AreEqual("E 0º 0' 0\"", lng.ToString(), "Longitude not expected"); Coordinate c = new Coordinate(); c.Latitude = lat; c.Longitude = lng; Assert.AreEqual("N 0º 0' 0\" E 0º 0' 0\"", c.ToString(), "Coordinate not expected"); }