public static Boolean ParseDistanceType(string distanceTypeStr, ref Data.DistanceTypes distanceType) { Boolean success = false; Data.DistanceTypes testType; if (Enum.TryParse(distanceTypeStr, true, out testType)) { distanceType = testType; success = true; } return(success); }
public void ParseDistanceTypeTest() { // create a Data object Data expectedData = new Data(); Data.DistanceTypes actualDistanceType = expectedData.DistanceType; // get test data string distanceType = Convert.ToString(TestContext.DataRow["DistanceType"]); // determine the distanceType via helper methods below ConvertDistanceTypeString(expectedData, distanceType); // run test ParseStrings.ParseDistanceType(distanceType, ref actualDistanceType); // validate results Assert.AreEqual(expectedData.DistanceType, actualDistanceType, "Distance types differed."); }