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

Skip to content
Snippets Groups Projects
Commit f15e077b authored by Harald Martini's avatar Harald Martini
Browse files

added Parse method to AlternatorTypeHelper

parent 188c7e7a
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,20 @@ namespace TUGraz.VectoCommon.Models
public static class AlternatorTypeHelper
{
public static AlternatorType Parse(string xmlFormat)
{
switch (xmlFormat) {
case "conventional":
return AlternatorType.Conventional;
case "smart":
return AlternatorType.Smart;
case "no alternator":
return AlternatorType.None;
default:
throw new ArgumentException();
}
}
public static string ToXMLFormat(this AlternatorType type)
{
......
......@@ -61,9 +61,9 @@ namespace TUGraz.VectoCore.InputData.FileIO.XML.Declaration.DataProvider
{
get
{
return GetString(new[]
{ XMLNames.BusAux_ElectricSystem, XMLNames.BusAux_ElectricSystem_AlternatorTechnology })
.ParseEnum<AlternatorType>();
return AlternatorTypeHelper.Parse(GetString(new[]
{ XMLNames.BusAux_ElectricSystem, XMLNames.BusAux_ElectricSystem_AlternatorTechnology }));
//.ParseEnum<AlternatorType>();
}
}
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Schema;
using NUnit.Framework;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Tests.XML
{
[TestFixture]
internal class XMLSchemaTest
{
XmlSchemaSet _declJobSchemaSet = XMLValidator.GetXMLSchema(XmlDocumentType.DeclarationJobData);
[TestCase("conventional", AlternatorType.Conventional)]
[TestCase("no alternator", AlternatorType.None)]
[TestCase("smart", AlternatorType.Smart)]
public void ParseAlternatorEnum(string xmlValue, AlternatorType expected)
{
var enumResult = AlternatorTypeHelper.Parse(xmlValue);
Assert.AreEqual(expected, enumResult);
}
}
}
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