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

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

new parameterized tests in NUnit format (TestCase)

parent d2339898
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DefineConstants>DEBUG</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
......
......@@ -31,9 +31,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using iTextSharp.text.pdf;
using TUGraz.VectoCommon.Exceptions;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
......@@ -59,7 +57,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
protected IDriverStrategy DriverStrategy;
private Dictionary<string, object> _coastData = new Dictionary<string, object>(20);
private string CurrentAction = "";
private string _currentAction = "";
//public MeterPerSquareSecond LookaheadDeceleration { get; protected set; }
......@@ -157,7 +155,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
IResponse previousResponse = null)
{
IterationStatistics.Increment(this, "Accelerate");
CurrentAction = "Accelerate";
_currentAction = "Accelerate";
Log.Debug("DrivingAction Accelerate");
var operatingPoint = ComputeAcceleration(ds, targetVelocity);
......@@ -237,7 +235,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
public IResponse DrivingActionCoast(Second absTime, Meter ds, MeterPerSecond maxVelocity, Radian gradient)
{
IterationStatistics.Increment(this, "Coast");
CurrentAction = "Coast";
_currentAction = "Coast";
Log.Debug("DrivingAction Coast");
return CoastOrRollAction(absTime, ds, maxVelocity, gradient, false);
......@@ -253,7 +251,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// <returns></returns>
public IResponse DrivingActionRoll(Second absTime, Meter ds, MeterPerSecond maxVelocity, Radian gradient)
{
CurrentAction = "Roll";
_currentAction = "Roll";
IterationStatistics.Increment(this, "Roll");
Log.Debug("DrivingAction Roll");
......@@ -359,7 +357,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
IResponse previousResponse = null, Meter targetDistance = null)
{
IterationStatistics.Increment(this, "Brake");
CurrentAction = "Brake";
_currentAction = "Brake";
Log.Debug("DrivingAction Brake");
IResponse retVal = null;
......@@ -767,7 +765,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
/// <returns></returns>
public IResponse DrivingActionHalt(Second absTime, Second dt, MeterPerSecond targetVelocity, Radian gradient)
{
CurrentAction = "Halt";
_currentAction = "Halt";
if (!targetVelocity.IsEqual(0) || !DataBus.VehicleStopped) {
Log.Error("TargetVelocity ({0}) and VehicleVelocity ({1}) must be zero when vehicle is halting!", targetVelocity,
DataBus.VehicleSpeed);
......@@ -795,14 +793,14 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
container[ModalResultField.acc] = CurrentState.Acceleration;
//todo mk-2016-05-11: remove additional columns in moddata after testing of LAC finished
foreach (var kv in _coastData) {
container.SetDataValue(kv.Key, kv.Value);
}
container.SetDataValue("Alt", DataBus.Altitude.Value());
container.SetDataValue("DrivingMode", ((DefaultDriverStrategy)DriverStrategy).CurrentDrivingMode);
container.SetDataValue("Action", CurrentAction);
_coastData.Clear();
////todo mk-2016-05-11: remove additional columns in moddata after testing of LAC finished
//foreach (var kv in _coastData) {
// container.SetDataValue(kv.Key, kv.Value);
//}
//container.SetDataValue("Alt", DataBus.Altitude.Value());
//container.SetDataValue("DrivingMode", ((DefaultDriverStrategy)DriverStrategy).CurrentDrivingMode);
//container.SetDataValue("Action", _currentAction);
//_coastData.Clear();
}
protected override void DoCommitSimulationStep()
......
......@@ -13,6 +13,7 @@
<FileAlignment>512</FileAlignment>
<CodeContractsAssemblyMode>1</CodeContractsAssemblyMode>
<NuGetPackageImportStamp>5f3566e7</NuGetPackageImportStamp>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -69,6 +70,7 @@
<CodeContractsRuntimeCheckingLevel>Full</CodeContractsRuntimeCheckingLevel>
<CodeContractsReferenceAssembly>%28none%29</CodeContractsReferenceAssembly>
<CodeContractsAnalysisWarningLevel>3</CodeContractsAnalysisWarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
......@@ -78,6 +80,8 @@
</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="itextsharp">
......
......@@ -63,7 +63,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
(internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed);
Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-4);
Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-3);
}
[Test]
......
......@@ -66,7 +66,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
(internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed);
Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-4);
Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-3);
}
[Test]
......@@ -98,7 +98,7 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
var torque = busAux.PowerDemand(0.SI<Second>(), 1.SI<Second>(), engineDrivelinePower / engineSpeed,
(internalPower * 1000).SI<Watt>() / engineSpeed, engineSpeed);
Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-4);
Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-3);
}
[Test]
......@@ -124,7 +124,6 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
Assert.AreEqual(expectedPowerDemand, (torque * engineSpeed).Value(), 1e-3);
}
[Test,
TestCase(19000)]
public void AuxDemandContinuityTest(double vehicleWeight)
......@@ -169,6 +168,5 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
//VectoCSVFile.Write("auxPowerDemand_EngineSpeed.csv", table);
}
}
}
\ No newline at end of file
......@@ -52,418 +52,6 @@ namespace TUGraz.VectoCore.Tests.Integration
return DrivingCycleDataReader.ReadFromStream(cycleData, CycleType.DistanceBased, "", false);
}
#region Accelerate
public static readonly string[] CycleAccelerate_20_60_Level = {
// <s>,<v>,<grad>,<stop>
" 0, 20, 0, 0",
" 100, 60, 0, 0",
"1000, 60, 0, 0"
};
public static readonly string[] CycleAccelerate_20_60_uphilll_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 20, 5, 0",
" 100, 60, 5, 0",
"1000, 60, 5, 0"
};
public static readonly string[] CycleAccelerate_20_60_downhill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 20, -5, 0",
" 100, 60, -5, 0",
"1000, 60, -5, 0"
};
public static readonly string[] CycleAccelerate_20_60_uphill_25 = {
// <s>,<v>,<grad>,<stop>
" 0, 20, 25, 0",
" 100, 60, 25, 0",
"1000, 60, 25, 0"
};
public static readonly string[] CycleAccelerate_20_60_downhill_25 = {
// <s>,<v>,<grad>,<stop>
" 0, 20, -25, 0",
" 100, 60, -25, 0",
"1000, 60, -25, 0"
};
public static readonly string[] CycleAccelerate_20_60_uphill_15 = {
// <s>,<v>,<grad>,<stop>
" 0, 20, 15, 0",
" 100, 60, 15, 0",
"1000, 60, 15, 0"
};
public static readonly string[] CycleAccelerate_20_60_downhill_15 = {
// <s>,<v>,<grad>,<stop>
" 0, 20, -15, 0",
" 100, 60, -15, 0",
"1000, 60, -15, 0"
};
public static readonly string[] CycleAccelerate_0_85_level = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 0, 2",
"1000, 85, 0, 0"
};
public static readonly string[] CycleAccelerate_0_85_uphill_1 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 1, 2",
"1000, 85, 1, 0"
};
public static readonly string[] CycleAccelerate_0_85_uphill_2 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 2, 2",
"1000, 85, 2, 0"
};
public static readonly string[] CycleAccelerate_0_85_uphill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 5, 2",
"1000, 85, 5, 0"
};
public static readonly string[] CycleAccelerate_0_85_downhill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 0, 2",
" 0, 85, -5, 0",
"1000, 85, -5, 0"
};
public static readonly string[] CycleAccelerate_0_85_downhill_3 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 0, 2",
" 0, 85, -3, 0",
"1000, 85, -3, 0"
};
public static readonly string[] CycleAccelerate_0_85_downhill_1 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 0, 2",
" 0, 85, -1, 0",
"1000, 85, -1, 0"
};
public static readonly string[] CycleAccelerate_0_60_downhill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 0, 2",
" 0, 60, -5, 0",
"1000, 60, -5, 0"
};
public static readonly string[] CycleAccelerate_0_60_downhill_3 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 0, 2",
" 0, 60, -3, 0",
"1000, 60, -3, 0"
};
public static readonly string[] CycleAccelerate_0_60_downhill_1 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 0, 2",
" 0, 60, -1, 0",
"1000, 60, -1, 0"
};
public static readonly string[] CycleAccelerate_0_40_downhill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 0, 2",
" 0, 40, -5, 0",
"1000, 40, -5, 0"
};
public static readonly string[] CycleAccelerate_0_40_downhill_3 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 0, 2",
" 0, 40, -3, 0",
"1000, 40, -3, 0"
};
public static readonly string[] CycleAccelerate_0_40_downhill_1 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 0, 2",
" 0, 40, -1, 0",
"1000, 40, -1, 0"
};
public static readonly string[] CycleAccelerate_0_85_uphill_25 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 0, 2",
" 0, 85, 25, 0",
"1000, 85, 25, 0"
};
public static readonly string[] CycleAccelerate_0_85_downhill_25 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, -25, 2",
"1000, 85, -25, 0"
};
public static readonly string[] CycleAccelerate_0_85_uphill_10 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 10, 2",
"1000, 85, 10, 0"
};
public static readonly string[] CycleAccelerate_0_85_downhill_15 = {
// <s>,<v>,<grad>,<stop>
" 0, 0, -15, 2",
"1000, 85, -15, 0"
};
public static readonly string[] CycleAccelerate_stop_0_85_level = {
// <s>,<v>,<grad>,<stop>
" 0, 0, 0, 2",
"1000, 85, 0, 0"
};
public static readonly string[] CycleAccelerate_20_22_uphill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 20, 5, 0",
" 100, 22, 5, 0",
" 200, 22, 5, 0"
};
#endregion
#region Decelerate
public static readonly string[] CycleDecelerate_22_20_downhill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 22, -5, 0",
" 100, 20, -5, 0",
" 300, 20, -5, 0"
};
public static readonly string[] CycleDecelerate_60_20_level = {
// <s>,<v>,<grad>,<stop>
" 0, 60, 0, 0",
"1000, 20, 0, 0",
"1100, 20, 0, 0"
};
public static readonly string[] CycleDecelerate_45_0_level = {
// <s>,<v>,<grad>,<stop>
" 0, 45, 0, 0",
" 200, 0, 0, 2"
};
public static readonly string[] CycleDecelerate_45_0_uphill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 45, 5, 0",
" 200, 0, 5, 2"
};
public static readonly string[] CycleDecelerate_45_0_downhill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 45, -5, 0",
" 200, 0, -5, 2"
};
public static readonly string[] CycleDecelerate_60_20_uphill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 60, 5, 0",
"1000, 20, 5, 0",
"1100, 20, 5, 0"
};
public static readonly string[] CycleDecelerate_60_20_downhill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 60, -5, 0",
"1000, 20, -5, 0",
"1100, 20, -5, 0"
};
public static readonly string[] CycleDecelerate_60_20_uphill_25 = {
// <s>,<v>,<grad>,<stop>
" 0, 60, 25, 0",
"1000, 20, 25, 0"
};
public static readonly string[] CycleDecelerate_60_20_downhill_25 = {
// <s>,<v>,<grad>,<stop>
" 0, 60, -25, 0",
"1000, 20, -25, 0",
"1100, 20, -25, 0"
};
public static readonly string[] CycleDecelerate_60_20_uphill_15 = {
// <s>,<v>,<grad>,<stop>
" 0, 60, 15, 0",
"1000, 20, 15, 0",
"1100, 20, 0, 0"
};
public static readonly string[] CycleDecelerate_60_20_downhill_15 = {
// <s>,<v>,<grad>,<stop>
" 0, 60, -15, 0",
" 800, 20, -15, 0",
"1000, 20, -15, 0"
};
public static readonly string[] CycleDecelerate_80_0_level = {
// <s>,<v>,<grad>,<stop>
" 0, 80, 0, 0",
"1000, 0, 0, 2"
// "1000, 0, 5, 2",
};
public static readonly string[] CycleDecelerate_80_0_uphill_3 = {
// <s>,<v>,<grad>,<stop>
" 0, 80, 3, 0",
"1000, 0, 3, 2"
// "1000, 0, 5, 2",
};
public static readonly string[] CycleDecelerate_80_0_uphill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 80, 5, 0",
"1000, 0, 5, 2"
// "1000, 0, 5, 2",
};
public static readonly string[] CycleDecelerate_80_0_downhill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 80, -5, 0",
" 500, 0, -5, 2"
};
public static readonly string[] CycleDecelerate_80_0_uphill_25 = {
// <s>,<v>,<grad>,<stop>
" 0, 80, 25, 0",
" 500, 0, 25, 2"
};
public static readonly string[] CycleDecelerate_80_0_downhill_25 = {
// <s>,<v>,<grad>,<stop>
" 0, 80, -25, 0",
"1000, 0, -25, 2"
};
public static readonly string[] CycleDecelerate_80_0_uphill_15 = {
// <s>,<v>,<grad>,<stop>
" 0, 80, 15, 0",
"1000, 0, 15, 0"
};
public static readonly string[] CycleDecelerate_80_0_uphill_20 = {
// <s>,<v>,<grad>,<stop>
" 0, 80, 20, 0",
"1000, 0, 20, 0"
};
public static readonly string[] CycleDecelerate_80_0_downhill_15 = {
// <s>,<v>,<grad>,<stop>
" 0, 80, -15, 0",
"1000, 0, -15, 2"
};
#endregion
#region Drive
public static readonly string[] CycleDrive_80_level = {
// <s>,<v>,<grad>,<stop>
" 0, 80, 0, 0",
"1000, 80, 0, 0"
};
public static readonly string[] CycleDrive_80_uphill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 80, 5, 0",
"1000, 80, 5, 0"
};
public static readonly string[] CycleDrive_80_downhill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 80, -5, 0",
" 1000, 80, -5, 0"
};
public static readonly string[] CycleDrive_20_downhill_15 = {
// <s>, <v>, <grad>, <stop>
" 0, 20, -15, 0",
" 500, 20, -25, 0"
};
public static readonly string[] CycleDrive_30_downhill_15 = {
// <s>, <v>, <grad>, <stop>
" 0, 30, -15, 0",
" 500, 30, -15, 0"
};
public static readonly string[] CycleDrive_50_downhill_15 = {
// <s>, <v>, <grad>, <stop>
" 0, 50, -15, 0",
" 500, 50, -15, 0"
};
public static readonly string[] CycleDrive_80_uphill_25 = {
// <s>,<v>,<grad>,<stop>
" 0, 80, 25, 0",
" 500, 80, 25, 0"
};
public static readonly string[] CycleDrive_80_downhill_15 = {
// <s>, <v>, <grad>, <stop>
" 0, 80, -15, 0",
" 500, 80, -15, 0"
};
public static readonly string[] CycleDrive_80_uphill_15 = {
// <s>,<v>,<grad>,<stop>
" 0, 80, 15, 0",
" 500, 80, 15, 0"
};
public static readonly string[] CycleDrive_10_level = {
// <s>,<v>,<grad>,<stop>
" 0, 10, 0, 0",
"200, 10, 0, 0"
};
public static readonly string[] CycleDrive_10_uphill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 10, 5, 0",
"200, 10, 5, 0"
};
public static readonly string[] CycleDrive_10_downhill_5 = {
// <s>,<v>,<grad>,<stop>
" 0, 10, -5, 0",
" 200, 10, -5, 0"
};
public static readonly string[] CycleDrive_10_downhill_25 = {
// <s>, <v>, <grad>, <stop>
" 0, 10, -25, 0",
" 200, 10, -25, 0"
};
public static readonly string[] CycleDrive_10_uphill_25 = {
// <s>,<v>,<grad>,<stop>
" 0, 10, 25, 0",
" 200, 10, 25, 0"
};
public static readonly string[] CycleDrive_10_downhill_15 = {
// <s>, <v>, <grad>, <stop>
" 0, 10, -15, 0",
" 200, 10, -15, 0"
};
public static readonly string[] CycleDrive_10_uphill_15 = {
// <s>,<v>,<grad>,<stop>
" 0, 10, 15, 0",
" 200, 10, 15, 0"
};
#endregion
#region Misc
public const string CycleDrive_80_Increasing_Slope =
......@@ -672,6 +260,19 @@ namespace TUGraz.VectoCore.Tests.Integration
2000, 0, 0, 2
3000, 85, 0, 0";
public const string CycleDrive_SlopeChangeBeforeStop =
// <s>,<v>,<grad>,<stop>
@" 0, 60, -1.4, 0
298, 60, -1.7, 0
300, 0, -1.7, 4";
public const string CycleDriver_FrequentSlopChange =
// <s>,<v>,<grad>,<stop>
@" 0, 60, 0, 0
10, 60, -6, 0
100, 55, -6, 0
300, 55, -6, 0";
#endregion
public static DrivingCycleData ReadDeclarationCycle(string missionType)
......
......@@ -29,12 +29,9 @@
* Martin Rexeis, rexeis@ivt.tugraz.at, IVT, Graz University of Technology
*/
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Reflection;
using NUnit.Framework;
using TUGraz.VectoCommon.Models;
using TUGraz.VectoCommon.Utils;
......@@ -63,12 +60,6 @@ namespace TUGraz.VectoCore.Tests.Models.SimulationComponent
private const string TruckEngine = @"TestData\Components\40t_Long_Haul_Truck.veng";
[TestCase]
public static void ClassInitialize(TestContext ctx)
{
AppDomain.CurrentDomain.SetData("DataDirectory", Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
}
[TestCase]
public void TestEngineHasOutPort()
{
......
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