Code development platform for open source projects from the European Union institutions

Skip to content
Snippets Groups Projects
Commit 502aa5e7 authored by Markus Quaritsch's avatar Markus Quaritsch
Browse files

adding testcase to read vehicle category 'rigid lorry', adapt declaration xml reader

parent 298c9146
No related branches found
No related tags found
No related merge requests found
......@@ -91,7 +91,7 @@ namespace TUGraz.VectoCommon.Models
case VehicleCategory.InterurbanBus:
return "Interurban Bus";
case VehicleCategory.RigidTruck:
return "Rigid Truck";
return "Rigid Lorry";
default:
throw new ArgumentOutOfRangeException("vehicleCategory", vehicleCategory, null);
}
......
......@@ -79,7 +79,11 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration
public VehicleCategory VehicleCategory
{
get { return GetElementValue(XMLNames.Vehicle_VehicleCategory).ParseEnum<VehicleCategory>(); }
get { var val = GetElementValue(XMLNames.Vehicle_VehicleCategory);
if ("Rigid Lorry".Equals(val, StringComparison.InvariantCultureIgnoreCase)) {
return VehicleCategory.RigidTruck;
}
return val.ParseEnum<VehicleCategory>(); }
}
public Kilogram CurbMassChassis
......
......@@ -629,6 +629,9 @@ namespace TUGraz.VectoCore.Tests.XML
var vehicleCategories = GetEnumOptions("VehicleCategoryDeclarationType", "1.0");
var allowedCategories = DeclarationData.Segments.GetVehicleCategories();
foreach (var vehicleCategory in vehicleCategories) {
if (vehicleCategory.Equals("Rigid Truck")) {
continue; // Rigid Truck has been renamed to Rigid Lorry. The XML contains this entry for backward compatibility (separate testcase)
}
var reader = XmlReader.Create(SampleVehicleDecl);
var doc = new XmlDocument();
......@@ -984,6 +987,33 @@ namespace TUGraz.VectoCore.Tests.XML
Assert.AreEqual(PredictiveCruiseControlType.None, adas.PredictiveCruiseControl);
}
[TestCase(SampleVehicleFullDeclUpdated)]
public void TestRigidTruckIsReadAsRigidLorry(string file)
{
var reader = XmlReader.Create(file);
var doc = new XmlDocument();
doc.Load(reader);
var nav = doc.CreateNavigator();
var manager = new XmlNamespaceManager(nav.NameTable);
var helper = new XPathHelper(ExecutionMode.Declaration);
helper.AddNamespaces(manager);
var vehicleCategoryNode = nav.SelectSingleNode(helper.QueryAbs(
helper.NSPrefix(XMLNames.VectoInputDeclaration, Constants.XML.RootNSPrefix),
XMLNames.Component_Vehicle,
XMLNames.Vehicle_VehicleCategory), manager);
vehicleCategoryNode.SetValue("Rigid Truck");
var modified = XmlReader.Create(new StringReader(nav.OuterXml));
var inputDataProvider = new XMLDeclarationInputDataProvider(modified, true);
var vehCategory = inputDataProvider.JobInputData.Vehicle.VehicleCategory;
Assert.AreEqual(VehicleCategory.RigidTruck, vehCategory);
}
public static string[] GetEnumOptions(string xmlType, string schemaVersion)
{
Stream resource;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment