public void TestCaculateDistance(string testData) { //Assign var xDoc = XDocument.Load(testData); var testCases = xDoc.Root.Elements("Case") .Select(p => new { Models = p.Elements("MeasureModel").Select(model => new MeasureViewModel() { Row1 = model.Element("Row1").Value, Col1 = model.Element("Col1").Value, Row2 = model.Element("Row2").Value, Col2 = model.Element("Col2").Value, GeoType = (MeasureType)Enum.Parse(typeof(MeasureType), model.Element("GeoType").Value), }).ToList(), ExpectedValue = p.Element("Expected").Value }).ToList(); foreach (var testCase in testCases) { var f1 = translateToDoubleValue(testCase.Models[0]); var f2 = translateToDoubleValue(testCase.Models[1]); //Act var result = DistanceHelper.CaculateDistance(f1, f2); //Assert Assert.Equal(testCase.ExpectedValue, result.Distance.ToString()); } }