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

Skip to content
Snippets Groups Projects
Commit e1b31565 authored by Michael KRISPER's avatar Michael KRISPER
Browse files

tests for whtc correction

parent 5289132b
No related branches found
No related tags found
No related merge requests found
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> <wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeStyle/CodeCleanup/SilentCleanupProfile/@EntryValue">Default: Reformat Code</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CommonFormatter/ALIGNMENT_TAB_FILL_STYLE/@EntryValue">USE_TABS_ONLY</s:String> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CommonFormatter/ALIGNMENT_TAB_FILL_STYLE/@EntryValue">USE_TABS_ONLY</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/ANONYMOUS_METHOD_DECLARATION_BRACES/@EntryValue">END_OF_LINE</s:String>
<s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">END_OF_LINE</s:String> <s:String x:Key="/Default/CodeStyle/CodeFormatting/CSharpFormat/CASE_BLOCK_BRACES/@EntryValue">END_OF_LINE</s:String>
......
namespace TUGraz.VectoCore.Models.Declaration using System.Data;
namespace TUGraz.VectoCore.Models.Declaration
{ {
public class DeclarationData public class DeclarationData
{ {
...@@ -12,6 +14,7 @@ ...@@ -12,6 +14,7 @@
private HeatingVentilationAirConditioning _heatingVentilationAirConditioning; private HeatingVentilationAirConditioning _heatingVentilationAirConditioning;
private PneumaticSystem _pneumaticSystem; private PneumaticSystem _pneumaticSystem;
private SteeringPump _steeringPump; private SteeringPump _steeringPump;
private WHTCCorrection _whtcCorrection;
public static Wheels Wheels public static Wheels Wheels
{ {
...@@ -62,9 +65,32 @@ ...@@ -62,9 +65,32 @@
get { return Instance()._steeringPump ?? (Instance()._steeringPump = new SteeringPump()); } get { return Instance()._steeringPump ?? (Instance()._steeringPump = new SteeringPump()); }
} }
public static WHTCCorrection WHTCCorrection
{
get { return Instance()._whtcCorrection ?? (Instance()._whtcCorrection = new WHTCCorrection()); }
}
private static DeclarationData Instance() private static DeclarationData Instance()
{ {
return _instance ?? (_instance = new DeclarationData()); return _instance ?? (_instance = new DeclarationData());
} }
} }
public class WHTCCorrection : LookupData<MissionType, double, double, double, double>
{
public override double Lookup(MissionType key1, double key2, double key3, double key4)
{
throw new System.NotImplementedException();
}
protected override string ResourceId
{
get { throw new System.NotImplementedException(); }
}
protected override void ParseData(DataTable table)
{
throw new System.NotImplementedException();
}
}
} }
\ No newline at end of file
Part,Long haul,Regional delivery,Urban delivery,Municipal utility,Construction,Heavy Urban,Urban,Suburban,Interurban,Coach Part,Long haul,Regional delivery,Urban delivery,Municipal utility,Construction,Heavy Urban,Urban,Suburban,Interurban,Coach
Urban,11,17,69,98,62,100,100,100,45,0 Urban,0.11,0.17,0.69,0.98,0.62,1.0,1.0,1.0,0.45,0.0
Rural,0,30,27,0,32,0,0,0,36,22 Rural,0.0,0.3,0.27,0.0,0.32,0.0,0.0,0.0,0.36,0.22
Motorway,89,53,4,2,6,0,0,0,19,78 Motorway,0.89,0.53,0.04,0.02,0.06,0.0,0.0,0.0,0.19,0.78
...@@ -9,12 +9,13 @@ using TUGraz.VectoCore.Models.SimulationComponent.Data; ...@@ -9,12 +9,13 @@ using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Tests.Utils; using TUGraz.VectoCore.Tests.Utils;
using TUGraz.VectoCore.Utils; using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Tests.Models namespace TUGraz.VectoCore.Tests.Models.Declaration
{ {
[TestClass] [TestClass]
public class DeclarationDataTest public class DeclarationDataTest
{ {
public const double Tolerance = 0.0001; private const double Tolerance = 0.0001;
private MissionType[] missions = Enum.GetValues(typeof(MissionType)).Cast<MissionType>().ToArray();
[TestMethod] [TestMethod]
public void WheelDataTest() public void WheelDataTest()
...@@ -81,6 +82,42 @@ namespace TUGraz.VectoCore.Tests.Models ...@@ -81,6 +82,42 @@ namespace TUGraz.VectoCore.Tests.Models
Assert.Inconclusive(); Assert.Inconclusive();
} }
[TestMethod]
public void WHTCWeightingTest()
{
var whtc = DeclarationData.WHTCCorrection;
var factors = new {
urban = new[] { 0.11, 0.17, 0.69, 0.98, 0.62, 1.0, 1.0, 1.0, 0.45, 0.0 },
rural = new[] { 0.0, 0.3, 0.27, 0.0, 0.32, 0.0, 0.0, 0.0, 0.36, 0.22 },
motorway = new[] { 0.89, 0.53, 0.04, 0.02, 0.06, 0.0, 0.0, 0.0, 0.19, 0.78 }
};
var r = new Random();
for (var i = 0; i < missions.Length; i++) {
var urban = r.NextDouble() * 2;
var rural = r.NextDouble() * 2;
var motorway = r.NextDouble() * 2;
double whtcValue = whtc.Lookup(missions[i], urban, rural, motorway);
Assert.AreEqual(urban * factors.urban[i] + rural * factors.rural[i] + motorway * factors.motorway[i], whtcValue);
}
Assert.Inconclusive();
}
[TestMethod]
public void VCDVTest()
{
Assert.Inconclusive();
}
[TestMethod]
public void DefaultTCTest()
{
Assert.Inconclusive();
}
[TestMethod] [TestMethod]
public void AuxElectricSystemTest() public void AuxElectricSystemTest()
{ {
...@@ -152,17 +189,8 @@ namespace TUGraz.VectoCore.Tests.Models ...@@ -152,17 +189,8 @@ namespace TUGraz.VectoCore.Tests.Models
} }
}; };
var missions = new[] {
MissionType.LongHaul, MissionType.RegionalDelivery, MissionType.UrbanDelivery, MissionType.MunicipalUtility,
MissionType.Construction, MissionType.HeavyUrban, MissionType.Urban,
MissionType.Suburban, MissionType.Interurban, MissionType.Coach
};
Assert.AreEqual(missions.Length, Enum.GetValues(typeof(MissionType)).Length, "something wrong in the mission list.");
Assert.IsTrue(expected.All(kv => kv.Value.Length == missions.Length), "something wrong in the test values lists.");
for (var i = 0; i < missions.Length; i++) { for (var i = 0; i < missions.Length; i++) {
// default // default tech
Watt defaultValue = fan.Lookup(missions[i], ""); Watt defaultValue = fan.Lookup(missions[i], "");
Assert.AreEqual(expected[defaultFan][i], defaultValue.Double(), Tolerance); Assert.AreEqual(expected[defaultFan][i], defaultValue.Double(), Tolerance);
...@@ -194,15 +222,6 @@ namespace TUGraz.VectoCore.Tests.Models ...@@ -194,15 +222,6 @@ namespace TUGraz.VectoCore.Tests.Models
{ "12", new[] { 0, 0, 0, 0, 200, 0, 0, 0, 0, 0 } } { "12", new[] { 0, 0, 0, 0, 200, 0, 0, 0, 0, 0 } }
}; };
var missions = new[] {
MissionType.LongHaul, MissionType.RegionalDelivery, MissionType.UrbanDelivery, MissionType.MunicipalUtility,
MissionType.Construction, MissionType.HeavyUrban, MissionType.Urban,
MissionType.Suburban, MissionType.Interurban, MissionType.Coach
};
Assert.AreEqual(missions.Length, Enum.GetValues(typeof(MissionType)).Length, "something wrong in the mission list.");
Assert.IsTrue(expected.All(kv => kv.Value.Length == missions.Length), "something wrong in the test values lists.");
for (var i = 0; i < missions.Length; i++) { for (var i = 0; i < missions.Length; i++) {
foreach (var expect in expected) { foreach (var expect in expected) {
Watt value = hvac.Lookup(missions[i], expect.Key); Watt value = hvac.Lookup(missions[i], expect.Key);
...@@ -231,15 +250,6 @@ namespace TUGraz.VectoCore.Tests.Models ...@@ -231,15 +250,6 @@ namespace TUGraz.VectoCore.Tests.Models
{ "12", new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } } { "12", new[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }
}; };
var missions = new[] {
MissionType.LongHaul, MissionType.RegionalDelivery, MissionType.UrbanDelivery, MissionType.MunicipalUtility,
MissionType.Construction, MissionType.HeavyUrban, MissionType.Urban,
MissionType.Suburban, MissionType.Interurban, MissionType.Coach
};
Assert.AreEqual(missions.Length, Enum.GetValues(typeof(MissionType)).Length, "something wrong in the mission list.");
Assert.IsTrue(expected.All(kv => kv.Value.Length == missions.Length), "something wrong in the test values lists.");
for (var i = 0; i < missions.Length; i++) { for (var i = 0; i < missions.Length; i++) {
foreach (var expect in expected) { foreach (var expect in expected) {
Watt value = ps.Lookup(missions[i], expect.Key); Watt value = ps.Lookup(missions[i], expect.Key);
...@@ -296,27 +306,10 @@ namespace TUGraz.VectoCore.Tests.Models ...@@ -296,27 +306,10 @@ namespace TUGraz.VectoCore.Tests.Models
} }
}; };
var missions = new[] {
MissionType.LongHaul,
MissionType.RegionalDelivery,
MissionType.UrbanDelivery,
MissionType.MunicipalUtility,
MissionType.Construction,
MissionType.HeavyUrban,
MissionType.Urban,
MissionType.Suburban,
MissionType.Interurban,
MissionType.Coach
};
Assert.AreEqual(missions.Length, Enum.GetValues(typeof(MissionType)).Length, "something wrong in the mission list.");
foreach (var expect in expected) { foreach (var expect in expected) {
var technology = expect.Key; var technology = expect.Key;
foreach (var hdvClasses in expect.Value) { foreach (var hdvClasses in expect.Value) {
var hdvClass = hdvClasses.Key; var hdvClass = hdvClasses.Key;
Assert.IsTrue(expected.All(kv => hdvClasses.Value.Length == missions.Length),
"something wrong in the test values lists.");
for (var i = 0; i < missions.Length; i++) { for (var i = 0; i < missions.Length; i++) {
Watt value = sp.Lookup(missions[i], hdvClass, technology); Watt value = sp.Lookup(missions[i], hdvClass, technology);
Assert.AreEqual(hdvClasses.Value[i], value.Double(), Tolerance); Assert.AreEqual(hdvClasses.Value[i], value.Double(), Tolerance);
......
...@@ -70,7 +70,7 @@ ...@@ -70,7 +70,7 @@
<ItemGroup> <ItemGroup>
<Compile Include="Exceptions\ExceptionTests.cs" /> <Compile Include="Exceptions\ExceptionTests.cs" />
<Compile Include="Integration\EngineOnlyCycle\EngineOnlyCycleTest.cs" /> <Compile Include="Integration\EngineOnlyCycle\EngineOnlyCycleTest.cs" />
<Compile Include="Models\DeclarationDataTest.cs" /> <Compile Include="Models\DeclarationData\DeclarationDataTest.cs" />
<Compile Include="Models\SimulationComponentData\AccelerationCurveTest.cs" /> <Compile Include="Models\SimulationComponentData\AccelerationCurveTest.cs" />
<Compile Include="Models\SimulationComponentData\FuelConsumptionMapTest.cs" /> <Compile Include="Models\SimulationComponentData\FuelConsumptionMapTest.cs" />
<Compile Include="Models\SimulationComponentData\FullLoadCurveTest.cs" /> <Compile Include="Models\SimulationComponentData\FullLoadCurveTest.cs" />
...@@ -267,9 +267,7 @@ ...@@ -267,9 +267,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup />
<Folder Include="Models\DeclarationData\" />
</ItemGroup>
<Choose> <Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'"> <When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup> <ItemGroup>
......
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