Code development platform for open source projects from the European Union institutions :large_blue_circle: EU Login authentication by SMS has been phased out. To see alternatives please check here

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

adapting testcases to run under NUnit 3.7

parent 8f53b8a4
Branches
Tags
No related merge requests found
Showing
with 866 additions and 799 deletions
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\..\packages\NUnit3TestAdapter.3.8.0\build\net35\NUnit3TestAdapter.props" Condition="Exists('..\..\packages\NUnit3TestAdapter.3.8.0\build\net35\NUnit3TestAdapter.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
......@@ -16,6 +17,8 @@
<ReferencePath>$(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages</ReferencePath>
<IsCodedUITest>False</IsCodedUITest>
<TestProjectType>UnitTest</TestProjectType>
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
......@@ -68,6 +71,9 @@
<Name>VECTO</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Choose>
<When Condition="'$(VisualStudioVersion)' == '10.0' And '$(IsCodedUITest)' == 'True'">
<ItemGroup>
......@@ -88,6 +94,12 @@
</Choose>
<Import Project="$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets" Condition="Exists('$(VSToolsPath)\TeamTest\Microsoft.TestTools.targets')" />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('..\..\packages\NUnit3TestAdapter.3.8.0\build\net35\NUnit3TestAdapter.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\NUnit3TestAdapter.3.8.0\build\net35\NUnit3TestAdapter.props'))" />
</Target>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="NUnit.ConsoleRunner" version="3.7.0" targetFramework="net45" />
<package id="NUnit3TestAdapter" version="3.8.0" targetFramework="net45" />
</packages>
\ No newline at end of file
......@@ -6,6 +6,12 @@ Imports VectoAuxiliaries
Namespace IntegrationTests
<TestFixture>
Public Class AuxDemandTest
<OneTimeSetUp>
Public Sub RunBeforeAnyTests()
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory)
End Sub
'<TestCase(12000, 1256, 148, 148, 4537.96826)> ' without HVAC demand
'<TestCase(12000, 1256, -15, -50, 7405.0791)> ' without HVAC demand<Test>
<TestCase(12000, 1256, 148, 148, 6087.0317)>
......
ConsumerName, CycleName, Actuations
Brakes,Heavy urban
Brakes,Suburban,49
Brakes,Interurban,190
Brakes,Coach,27
Park break + 2 doors,Heavy urban,82
Park break + 2 doors,Urban,75
Park break + 2 doors,Suburban,25
Park break + 2 doors,Interurban,9
Park break + 2 doors,Coach,6
Kneeling,Heavy urban,27
Kneeling,Urban,25
Kneeling,Suburban,6
Kneeling,Interurban,0
Kneeling,Coach,0
\ No newline at end of file
ConsumerName, CycleName, Actuations
Brakes,Heavy urban,191
Brakes,Heavy urban,191.3
Brakes,Urban,153
Brakes,Suburban,49
Brakes,Interurban,190
......
......@@ -72,12 +72,12 @@ Namespace UnitTests
Assert.IsTrue(target.Initialise())
End Sub
<Test(), ExpectedException("System.ArgumentException")>
<Test()>
Public Sub InitialiseInvalidMapTest()
Dim map As ICompressorMap = GetFailingCompressorMapMock()
_signals.EngineSpeed = 100.RPMtoRad()
Dim target As M4_AirCompressor = New M4_AirCompressor(map, 2, 0.8, _signals)
target.Initialise()
Assert.That(Sub() target.Initialise(), Throws.InstanceOf(Of System.ArgumentException))
End Sub
<Test()>
......@@ -96,12 +96,12 @@ Namespace UnitTests
Assert.AreEqual(target, actual)
End Sub
<TestCase(TooLowEfficiency)> _
<TestCase(TooHighEfficiency)> _
<ExpectedException("System.ArgumentOutOfRangeException")>
<TestCase(TooLowEfficiency)>
<TestCase(TooHighEfficiency)>
Public Sub SetEfficiencyOutOfRangeTest(ByVal efficiency As Single)
Dim comp As M4_AirCompressor = GetGoodCompressor()
comp.PulleyGearEfficiency = efficiency
Assert.That(Sub() comp.PulleyGearEfficiency = efficiency, Throws.InstanceOf(Of ArgumentException))
End Sub
......@@ -121,12 +121,12 @@ Namespace UnitTests
Assert.AreEqual(target, actual)
End Sub
<TestCase(TooLowRatio)> _
<TestCase(TooHighRatio)> _
<ExpectedException("System.ArgumentOutOfRangeException")>
<TestCase(TooLowRatio)>
<TestCase(TooHighRatio)>
Public Sub SetRatioOutOfRangeTest(ByVal ratio As Single)
Dim comp As M4_AirCompressor = GetGoodCompressor()
comp.PulleyGearRatio = ratio
Assert.That(Sub() comp.PulleyGearRatio = ratio, Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()>
......
......@@ -34,60 +34,53 @@ Public Sub BusCreateTest()
End Sub
<Test()> _
<ExpectedException("System.ArgumentException")>
<Test()>
Public Sub IllegalFloorTypeTest()
Dim target As IBus = New Bus(2, "", "raised floor", "diesel", 10.655, 2.55, 2.275, 47, False)
Dim target As IBus
Assert.That(Sub() target = New Bus(2, "", "raised floor", "diesel", 10.655, 2.55, 2.275, 47, False), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()> _
<ExpectedException("System.ArgumentException")>
<Test()>
Public Sub IllegalModelTest()
Dim target As IBus = New Bus(3, "ABC", "raised", "diesel", 10.655, 2.55, 2.275, 47, False)
Dim target As IBus
Assert.That(Sub() target = New Bus(3, "ABC", "raised", "diesel", 10.655, 2.55, 2.275, 47, False), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()> _
<ExpectedException("System.ArgumentException")>
<Test()>
Public Sub IllegalEngineTypeTest()
Dim target As IBus = New Bus(4, "ABC", "raised floor", "vapour", 10.655, 2.55, 2.275, 47, False)
Dim target As IBus
Assert.That(Sub() target = New Bus(4, "ABC", "raised floor", "vapour", 10.655, 2.55, 2.275, 47, False), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()> _
<ExpectedException("System.ArgumentException")>
<Test()>
Public Sub IllegalWidthTest()
Dim target As IBus = New Bus(5, "IVECO - Arway Intercity 10.6m", "raised floor", "diesel", 10.655, 0, 2.275, 47, False)
Dim target As IBus
Assert.That(Sub() target = New Bus(5, "IVECO - Arway Intercity 10.6m", "raised floor", "diesel", 10.655, 0, 2.275, 47, False), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()> _
<ExpectedException("System.ArgumentException")>
<Test()>
Public Sub IllegalHeightTest()
Dim target As IBus = New Bus(6, "IVECO - Arway Intercity 10.6m", "raised floor", "diesel", 10.655, 2.55, 0, 47, False)
Dim target As IBus
Assert.That(Sub() target = New Bus(6, "IVECO - Arway Intercity 10.6m", "raised floor", "diesel", 10.655, 2.55, 0, 47, False), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()> _
<ExpectedException("System.ArgumentException")>
<Test()>
Public Sub IllegalLengthTest()
Dim target As IBus = New Bus(7, "IVECO - Arway Intercity 10.6m", "raised floor", "diesel", 0, 2.55, 2.275, 47, False)
Dim target As IBus
Assert.That(Sub() target = New Bus(7, "IVECO - Arway Intercity 10.6m", "raised floor", "diesel", 0, 2.55, 2.275, 47, False), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()> _
<ExpectedException("System.ArgumentException")>
<Test()>
Public Sub IllegalPassengersTest()
Dim target As IBus = New Bus(8, "IVECO - Arway Intercity 10.6m", "raised floor", "diesel", 10.655, 2.55, 2.275, 1, False)
Dim target As IBus
Assert.That(Sub() target = New Bus(8, "IVECO - Arway Intercity 10.6m", "raised floor", "diesel", 10.655, 2.55, 2.275, 1, False), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()>
......
......@@ -6,6 +6,7 @@ Imports VectoAuxiliaries.Electrics
Imports VectoAuxiliariesTests.Mocks
Imports VectoAuxiliaries
Imports VectoAuxiliaries.Hvac
Imports System.IO
Namespace UnitTests
......@@ -33,108 +34,108 @@ Namespace UnitTests
Sub New()
Alt1ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 50), _
New AltUserInput(10, 50), _
New AltUserInput(40, 50), _
New AltUserInput(60, 50), _
New AltUserInput(61, 50), _
Alt1ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 50),
New AltUserInput(10, 50),
New AltUserInput(40, 50),
New AltUserInput(60, 50),
New AltUserInput(61, 50),
New AltUserInput(200, 50)}
Alt1ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 70), _
New AltUserInput(10, 70), _
New AltUserInput(40, 70), _
New AltUserInput(60, 70), _
New AltUserInput(61, 70), _
Alt1ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 70),
New AltUserInput(10, 70),
New AltUserInput(40, 70),
New AltUserInput(60, 70),
New AltUserInput(61, 70),
New AltUserInput(200, 70)}
Alt1ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 60), _
New AltUserInput(10, 60), _
New AltUserInput(40, 60), _
New AltUserInput(60, 60), _
New AltUserInput(61, 60), _
Alt1ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 60),
New AltUserInput(10, 60),
New AltUserInput(40, 60),
New AltUserInput(60, 60),
New AltUserInput(61, 60),
New AltUserInput(200, 60)}
'ALT 2
Alt2ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 80), _
New AltUserInput(10, 80), _
New AltUserInput(40, 80), _
New AltUserInput(60, 80), _
New AltUserInput(61, 80), _
Alt2ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 80),
New AltUserInput(10, 80),
New AltUserInput(40, 80),
New AltUserInput(60, 80),
New AltUserInput(61, 80),
New AltUserInput(200, 80)}
Alt2ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 40), _
New AltUserInput(10, 40), _
New AltUserInput(40, 40), _
New AltUserInput(60, 40), _
New AltUserInput(61, 40), _
Alt2ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 40),
New AltUserInput(10, 40),
New AltUserInput(40, 40),
New AltUserInput(60, 40),
New AltUserInput(61, 40),
New AltUserInput(200, 40)}
Alt2ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 60), _
New AltUserInput(10, 60), _
New AltUserInput(40, 60), _
New AltUserInput(60, 60), _
New AltUserInput(61, 60), _
Alt2ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 60),
New AltUserInput(10, 60),
New AltUserInput(40, 60),
New AltUserInput(60, 60),
New AltUserInput(61, 60),
New AltUserInput(200, 60)}
'ALT 3
Alt3ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 95), _
New AltUserInput(10, 95), _
New AltUserInput(40, 50), _
New AltUserInput(60, 90), _
New AltUserInput(62.5, 95), _
Alt3ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 95),
New AltUserInput(10, 95),
New AltUserInput(40, 50),
New AltUserInput(60, 90),
New AltUserInput(62.5, 95),
New AltUserInput(200, 95)}
Alt3ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 99), _
New AltUserInput(10, 99), _
New AltUserInput(40, 1), _
New AltUserInput(60, 55), _
New AltUserInput(76.2962963, 99), _
Alt3ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 99),
New AltUserInput(10, 99),
New AltUserInput(40, 1),
New AltUserInput(60, 55),
New AltUserInput(76.2962963, 99),
New AltUserInput(200, 99)}
Alt3ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 94), _
New AltUserInput(10, 94), _
New AltUserInput(40, 86), _
New AltUserInput(60, 13), _
New AltUserInput(63.5616438, 0), _
Alt3ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 94),
New AltUserInput(10, 94),
New AltUserInput(40, 86),
New AltUserInput(60, 13),
New AltUserInput(63.5616438, 0),
New AltUserInput(200, 0)}
'ALT 4
Alt4ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 55), _
New AltUserInput(10, 55), _
New AltUserInput(40, 45), _
New AltUserInput(60, 67), _
New AltUserInput(61, 67), _
Alt4ExpectedTable2000 = New List(Of AltUserInput)() From {New AltUserInput(0, 55),
New AltUserInput(10, 55),
New AltUserInput(40, 45),
New AltUserInput(60, 67),
New AltUserInput(61, 67),
New AltUserInput(200, 67)}
Alt4ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 77), _
New AltUserInput(10, 77), _
New AltUserInput(40, 39), _
New AltUserInput(60, 23), _
New AltUserInput(88.75, 0), _
Alt4ExpectedTable4000 = New List(Of AltUserInput)() From {New AltUserInput(0, 77),
New AltUserInput(10, 77),
New AltUserInput(40, 39),
New AltUserInput(60, 23),
New AltUserInput(88.75, 0),
New AltUserInput(200, 0)}
Alt4ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 34), _
New AltUserInput(10, 34), _
New AltUserInput(40, 67), _
New AltUserInput(60, 35), _
New AltUserInput(81.875, 0), _
Alt4ExpectedTable6000 = New List(Of AltUserInput)() From {New AltUserInput(0, 34),
New AltUserInput(10, 34),
New AltUserInput(40, 67),
New AltUserInput(60, 35),
New AltUserInput(81.875, 0),
New AltUserInput(200, 0)}
'RangeTable
RangeTableExpected = New List(Of AltUserInput)() From {New AltUserInput(-3001, 0), _
New AltUserInput(-3000, 0), _
New AltUserInput(2000, 50), _
New AltUserInput(4000, 70), _
New AltUserInput(6000, 60), _
New AltUserInput(18000, 0), _
RangeTableExpected = New List(Of AltUserInput)() From {New AltUserInput(-3001, 0),
New AltUserInput(-3000, 0),
New AltUserInput(2000, 50),
New AltUserInput(4000, 70),
New AltUserInput(6000, 60),
New AltUserInput(18000, 0),
New AltUserInput(18001, 0)}
......@@ -147,18 +148,23 @@ Namespace UnitTests
End Sub
<Test()> _
<TestCase(1, 2, 50.0F)> _
<TestCase(1, 4, 70)> _
<TestCase(1, 6, 60)> _
<TestCase(2, 2, 80)> _
<TestCase(2, 4, 40)> _
<TestCase(2, 6, 60)> _
<TestCase(3, 2, 55)> _
<TestCase(3, 4, 7.75F)> _
<TestCase(3, 6, 76.875F)> _
<TestCase(4, 2, 47.75F)> _
<TestCase(4, 4, 37)> _
<OneTimeSetUp>
Public Sub RunBeforeAnyTests()
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory)
End Sub
<Test()>
<TestCase(1, 2, 50.0F)>
<TestCase(1, 4, 70)>
<TestCase(1, 6, 60)>
<TestCase(2, 2, 80)>
<TestCase(2, 4, 40)>
<TestCase(2, 6, 60)>
<TestCase(3, 2, 55)>
<TestCase(3, 4, 7.75F)>
<TestCase(3, 6, 76.875F)>
<TestCase(4, 2, 47.75F)>
<TestCase(4, 4, 37)>
<TestCase(4, 6, 63)>
Public Sub Interpolate4Table4(alt As Integer, rpmK As Integer, expected As Single)
......
Imports NUnit.Framework
Imports System.IO
Imports NUnit.Framework
Imports TUGraz.VectoCommon.Utils
Imports VectoAuxiliaries.Pneumatics
......@@ -30,6 +31,11 @@ Namespace UnitTests
#End Region
<OneTimeSetUp>
Public Sub RunBeforeAnyTests()
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory)
End Sub
<Test()>
Public Sub CreateNewCompressorMapInstanceTest()
Dim pat As String = "test"
......@@ -43,53 +49,53 @@ Namespace UnitTests
Assert.IsTrue(target.Initialise())
End Sub
<Test(), ExpectedException("System.ArgumentException")>
<Test()>
Public Sub InitialisationNoFileSuppliedThrowsExceptionTest()
Dim path As String = ""
Dim target As CompressorMap = New CompressorMap(path)
Assert.IsTrue(target.Initialise())
Assert.That(Sub() target.Initialise(), Throws.InstanceOf(Of System.ArgumentException))
End Sub
<Test(), ExpectedException("System.ArgumentException")>
<Test()>
Public Sub InitialisationWrongNumberOfColumnsThrowsExceptionTest()
Dim path As String = INVALIDNUMBEROFCOLUMNS
Dim target As CompressorMap = New CompressorMap(path)
target.Initialise()
Assert.That(Sub() target.Initialise(), Throws.InstanceOf(Of System.ArgumentException))
End Sub
<Test(), ExpectedException("System.InvalidCastException")>
<Test()>
Public Sub InitialisationInvalidRpmThrowsExceptionTest()
Dim path As String = INVALIDRPMMAP
Dim target As CompressorMap = New CompressorMap(path)
target.Initialise()
Assert.That(Sub() target.Initialise(), Throws.InstanceOf(Of System.InvalidCastException))
End Sub
<Test(), ExpectedException("System.InvalidCastException")>
<Test()>
Public Sub InitialisationInvalidFlowRateThrowsExceptionTest()
Dim path As String = INVALIDFLOWRATEMAP
Dim target As CompressorMap = New CompressorMap(path)
target.Initialise()
Assert.That(Sub() target.Initialise(), Throws.InstanceOf(Of System.InvalidCastException))
End Sub
<Test(), ExpectedException("System.InvalidCastException")>
<Test()>
Public Sub InitialisationInvalidPowerCompressorOnThrowsExceptionTest()
Dim path As String = INVALIDPOWERCOMPRESSORONMAP
Dim target As CompressorMap = New CompressorMap(path)
target.Initialise()
Assert.That(Sub() target.Initialise(), Throws.InstanceOf(Of System.InvalidCastException))
End Sub
<Test(), ExpectedException("System.InvalidCastException")>
<Test()>
Public Sub InitialisationInvalidPowerCompressorOffThrowsExceptionTest()
Dim path As String = INVALIDPOWERCOMPRESSOROFFMAP
Dim target As CompressorMap = New CompressorMap(path)
target.Initialise()
Assert.That(Sub() target.Initialise(), Throws.InstanceOf(Of System.InvalidCastException))
End Sub
<Test(), ExpectedException("System.ArgumentException")>
<Test()>
Public Sub InitialisationInsufficientRowsThrowsExceptionTest()
Dim path As String = INSSUFICIENTROWSMAP
Dim target As CompressorMap = New CompressorMap(path)
target.Initialise()
Assert.That(Sub() target.Initialise(), Throws.InstanceOf(Of System.ArgumentException))
End Sub
......
......@@ -46,12 +46,13 @@ Public Class ElectricalConsumerListTests
<Test()>
<ExpectedException("System.ArgumentException")>
Public Sub DuplicateConsumersTest_ThrowsArgumentException()
Dim target As New ElectricalConsumerList(0.096, 26.3)
'Add two OnBaseVehicle consumers
target.AddConsumer(New ElectricalConsumer(True, "TEST", "Exclude1", 10, 1, 26.3, 1, ""))
target.AddConsumer(New ElectricalConsumer(True, "TEST", "Exclude1", 10, 1, 26.3, 1, ""))
Assert.That(Sub() target.AddConsumer(New ElectricalConsumer(True, "TEST", "Exclude1", 10, 1, 26.3, 1, "")), Throws.InstanceOf(Of System.ArgumentException))
End Sub
End Class
......@@ -23,16 +23,17 @@ Namespace UnitTests
' <Test(), ExpectedException("System.ArgumentException")>
<Test(), ExpectedException("System.ArgumentException")>
<Test()>
Public Sub ZeroLengthConsumerNameTest()
Dim target As ElectricalConsumer
Assert.That(Sub() target = New ElectricalConsumer(False, "Doors", "", 20, 0.5, 26.3, 1, ""), Throws.InstanceOf(Of ArgumentException))
Dim target As New ElectricalConsumer(False, "Doors", "", 20, 0.5, 26.3, 1, "")
End Sub
<Test(), ExpectedException("System.ArgumentException")>
<Test()>
Public Sub ZeroLengthCategoryNameTest_ThrowsArgumentException()
Dim target As New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5, 26.3, 1, "")
Dim target As ElectricalConsumer
Assert.That(Sub() target = New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5, 26.3, 1, ""), Throws.InstanceOf(Of ArgumentException))
End Sub
......@@ -40,43 +41,44 @@ Namespace UnitTests
'TooHigh NominalConsumption
<Test(), ExpectedException("System.ArgumentException")>
<Test()>
Public Sub ToLow_PhaseIdleTractionOn_ThrowsArgumentException()
Dim _
target As _
New ElectricalConsumer(False, "", "Doors per Door", 20, ElectricConstants.PhaseIdleTractionOnMin - 1,
26.3, 1, "")
Dim target As ElectricalConsumer
Assert.That(Sub() target = New ElectricalConsumer(False, "", "Doors per Door", 20, ElectricConstants.PhaseIdleTractionOnMin - 1,
26.3, 1, ""), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test(), ExpectedException("System.ArgumentException")>
<Test()>
Public Sub ToHigh_PhaseIdleTractionOn_ThrowsArgumentException()
Dim _
target As _
New ElectricalConsumer(False, "", "Doors per Door", 20, ElectricConstants.PhaseIdleTractionMax + 1,
26.3, 1, "")
Dim target As ElectricalConsumer
Assert.That(Sub() target = New ElectricalConsumer(False, "", "Doors per Door", 20, ElectricConstants.PhaseIdleTractionMax + 1,
26.3, 1, ""), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test(), ExpectedException("System.ArgumentException")>
<Test()>
Public Sub ToLowNumberInVehicle_ThrowsArgumentException()
Dim target As New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5, 26.3, -1, "")
Dim target As ElectricalConsumer
Assert.That(Sub() target = New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5, 26.3, -1, ""), Throws.InstanceOf(Of ArgumentException))
End Sub
'TooLow PowerNetVoltage
<Test(), ExpectedException("System.ArgumentException")>
<Test()>
Public Sub ToLowPowerNetVoltageTest_ThrowsArgumentException()
Dim _
target As _
New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5,
(ElectricConstants.PowenetVoltageMin - 1), 1, "")
Dim target As ElectricalConsumer
Assert.That(Sub() target = New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5,
(ElectricConstants.PowenetVoltageMin - 1), 1, ""), Throws.InstanceOf(Of ArgumentException))
End Sub
'TooHigh PowerNetVoltage
<Test()>
Public Sub ToHighPowerNetVoltageTest_ThrowsArgumentException()
Dim _
target As _
New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5,
(ElectricConstants.PowenetVoltageMax + 1), 1, "")
Dim target As ElectricalConsumer
Assert.That(Sub() target = New ElectricalConsumer(False, "", "Doors per Door", 20, 0.5,
(ElectricConstants.PowenetVoltageMax + 1), 1, ""), Throws.InstanceOf(Of ArgumentException))
End Sub
End Class
End Namespace
\ No newline at end of file
......@@ -5,6 +5,7 @@ Imports VectoAuxiliaries.Pneumatics
Imports VectoAuxiliariesTests.Mocks
Imports VectoAuxiliaries.Electrics
Imports VectoAuxiliaries.Hvac
Imports System.IO
Namespace UnitTests
<TestFixture()>
......@@ -32,6 +33,8 @@ Namespace UnitTests
Public Sub New()
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory)
signals.EngineSpeed = 2000.RPMtoRad()
'Setup consumers and HVAC ( 1 Consumer in Test Category )
......@@ -44,6 +47,11 @@ Namespace UnitTests
alternatorMap.Initialise()
End Sub
<OneTimeSetUp>
Public Sub RunBeforeAnyTests()
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory)
End Sub
<Test()>
Public Sub CreateNewTest()
Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers,
......@@ -52,17 +60,16 @@ Namespace UnitTests
End Sub
<Test()>
<ExpectedException("System.ArgumentException")>
Public Sub CreateNew_MissingElecConsumers_ThrowArgumentExceptionTest()
Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(Nothing, alternatorMap,
powernetVoltage, signals, GetSSM())
Dim target As M0_NonSmart_AlternatorsSetEfficiency
Assert.That(Sub() target = New M0_NonSmart_AlternatorsSetEfficiency(Nothing, alternatorMap, powernetVoltage, signals, GetSSM()), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()>
<ExpectedException("System.ArgumentException")>
Public Sub CreateNew_MissingAlternatorMap_ThrowArgumentExceptionTest()
Dim target As M0_NonSmart_AlternatorsSetEfficiency = New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, Nothing,
powernetVoltage, signals, GetSSM())
Dim target As M0_NonSmart_AlternatorsSetEfficiency
Assert.That(Sub() target = New M0_NonSmart_AlternatorsSetEfficiency(elecConsumers, Nothing, powernetVoltage, signals, GetSSM()), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()>
......
Imports NUnit
Imports VectoAuxiliaries.Pneumatics
Imports NUnit.Framework
Imports System.IO
Namespace Pneumatics
......@@ -16,7 +17,10 @@ Public Const cstrPneumaticActuationsMapPath_INVALIDCONSUMERNAME As String = "Tes
Public Const cstrPneumaticActuationsMapPath_INVALIDCYCLENAME As String = "TestFiles\testPneumaticActuationsMap_INVALIDCYCLENAME.apac"
<OneTimeSetUp>
Public Sub RunBeforeAnyTests()
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory)
End Sub
<Test()>
Public Sub CreateNewTest()
......@@ -35,78 +39,71 @@ Public Sub InitialiseGoodMapTest()
End Sub
<Test()>
<ExpectedException("System.ArgumentException")>
<TestCase()>
Public Sub InitialiseWrongNumberOfColumnTest()
Dim target As New PneumaticActuationsMAP(cstrPneumaticActuationsMapPath_INCORRECTCOLUMNS)
target.Initialise()
Dim target As PneumaticActuationsMAP
Assert.That(Sub() target = New PneumaticActuationsMAP(cstrPneumaticActuationsMapPath_INCORRECTCOLUMNS), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()>
<ExpectedException("System.ArgumentException")>
Public Sub InvalidIntegerTest()
Dim target As New PneumaticActuationsMAP(cstrPneumaticActuationsMapPath_INVALIDINTEGERVALUE)
target.Initialise()
Dim target As PneumaticActuationsMAP
Assert.That(Sub() target = New PneumaticActuationsMAP(cstrPneumaticActuationsMapPath_INVALIDINTEGERVALUE), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()>
<ExpectedException("System.ArgumentException")>
Public Sub DuplicateKeyTest()
Dim target As New PneumaticActuationsMAP(cstrPneumaticActuationsMapPath_DUPLICATEKEY)
target.Initialise()
Dim target As PneumaticActuationsMAP
Assert.That(Sub() target = New PneumaticActuationsMAP(cstrPneumaticActuationsMapPath_DUPLICATEKEY), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()>
<ExpectedException("System.ArgumentException")>
Public Sub EmptyConsumerNameTest()
Dim target As New PneumaticActuationsMAP(cstrPneumaticActuationsMapPath_INVALIDCONSUMERNAME)
target.Initialise()
Dim target As PneumaticActuationsMAP
Assert.That(Sub() target = New PneumaticActuationsMAP(cstrPneumaticActuationsMapPath_DUPLICATEKEY), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()>
<ExpectedException("System.ArgumentException")>
Public Sub EmptyCycleNameTest()
Dim target As New PneumaticActuationsMAP(cstrPneumaticActuationsMapPath_INVALIDCYCLENAME)
target.Initialise()
Dim target As PneumaticActuationsMAP
Assert.That(Sub() target = New PneumaticActuationsMAP(cstrPneumaticActuationsMapPath_INVALIDCYCLENAME), Throws.InstanceOf(Of ArgumentException))
End Sub
<Test()>
<TestCase("Brakes","Heavy urban",191)> _
<TestCase("Brakes","Urban",153)> _
<TestCase("Brakes","Suburban",49)> _
<TestCase("Brakes","Interurban",190)> _
<TestCase("Brakes","Coach",27)> _
<TestCase("Park brake + 2 doors","Heavy urban",82)> _
<TestCase("Park brake + 2 doors","Urban",75)> _
<TestCase("Park brake + 2 doors","Suburban",25)> _
<TestCase("Park brake + 2 doors","Interurban",9)> _
<TestCase("Park brake + 2 doors","Coach",6)> _
<TestCase("Kneeling","Heavy urban",27)> _
<TestCase("Kneeling","Urban",25)> _
<TestCase("Kneeling","Suburban",6)> _
<TestCase("Kneeling","Interurban",0)> _
<TestCase("Kneeling","Coach",0)> _
Public Sub ValueLookupTest(key As String, cycle As String, expected As integer)
<TestCase("Brakes", "Heavy urban", 191)>
<TestCase("Brakes", "Urban", 153)>
<TestCase("Brakes", "Suburban", 49)>
<TestCase("Brakes", "Interurban", 190)>
<TestCase("Brakes", "Coach", 27)>
<TestCase("Park brake + 2 doors", "Heavy urban", 82)>
<TestCase("Park brake + 2 doors", "Urban", 75)>
<TestCase("Park brake + 2 doors", "Suburban", 25)>
<TestCase("Park brake + 2 doors", "Interurban", 9)>
<TestCase("Park brake + 2 doors", "Coach", 6)>
<TestCase("Kneeling", "Heavy urban", 27)>
<TestCase("Kneeling", "Urban", 25)>
<TestCase("Kneeling", "Suburban", 6)>
<TestCase("Kneeling", "Interurban", 0)>
<TestCase("Kneeling", "Coach", 0)>
Public Sub ValueLookupTest(key As String, cycle As String, expected As Integer)
Dim target As New PneumaticActuationsMAP(cstrPneumaticActuationsMapPath_GOODMAP)
target.Initialise()
Dim actual As Integer
try
Try
actual = target.GetNumActuations(New ActuationsKey(key, cycle))
Catch ex As Exception
end try
End Try
Assert.AreEqual(expected, actual)
End Sub
......
......@@ -40,12 +40,11 @@ Public Class ResultCardTests
End Sub
<Test()>
<ExpectedException("System.ArgumentException")>
Public Sub CreateNewBanResultsNullTest()
Dim target As New ResultCard(Nothing)
Dim target As ResultCard
Assert.That(Sub() target = New ResultCard(Nothing), Throws.InstanceOf(Of ArgumentException))
Assert.IsNotNull(target)
End Sub
......
......@@ -45,12 +45,20 @@ using Assert = NUnit.Framework.Assert;
namespace VectoHashingTest
{
[TestFixture]
public class VectoHashTest
{
public const string ReferenceXMLEngine = @"Testdata\XML\Reference\vecto_engine-sample.xml";
public const string ReferenceXMLVehicle = @"Testdata\XML\Reference\vecto_vehicle-sample_FULL.xml";
[OneTimeSetUp]
public void RunBeforeAnyTests()
{
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);
}
[TestCase]
public void TestComponentsEngineFile()
{
......@@ -334,8 +342,8 @@ namespace VectoHashingTest
var now = DateTime.Now;
Assert.AreNotEqual(date.ToString(), newDate.ToString());
Assert.IsTrue(now - date > new TimeSpan(0, 0, 0, 1));
Assert.IsTrue(now - newDate < new TimeSpan(0, 0, 0, 1));
Assert.IsTrue(now.ToUniversalTime() - date > new TimeSpan(0, 0, 0, 1));
Assert.IsTrue(now.ToUniversalTime() - newDate < new TimeSpan(0, 0, 0, 1));
}
[TestCase(@"Testdata\XML\ToHash\vecto_engine_withhash-input.xml", "input data already contains a signature element"),
......
......@@ -42,7 +42,7 @@ namespace TUGraz.VectoCore.ModelbasedTests.DriverStrategy
[TestFixture]
public class CoastingTests
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void DisableLogging()
{
//LogManager.DisableLogging();
......@@ -104,7 +104,7 @@ namespace TUGraz.VectoCore.ModelbasedTests.DriverStrategy
GraphWriter.Write(modFile);
}
[Ignore, Test,
[Ignore("no longer relevant"), Test,
TestCase(40),
TestCase(45),
TestCase(50),
......
......@@ -42,7 +42,7 @@ namespace TUGraz.VectoCore.ModelbasedTests.DriverStrategy
[TestFixture]
public class SimpleCycles
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void Init()
{
//LogManager.DisableLogging();
......
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="JetBrains.Annotations" version="10.1.4" targetFramework="net45" />
<package id="Newtonsoft.Json" version="8.0.3" targetFramework="net45" />
<package id="NLog" version="4.2.3" targetFramework="net45" />
<package id="System.Runtime" version="4.0.0" targetFramework="net45" />
</packages>
\ No newline at end of file
......@@ -40,9 +40,16 @@ using TUGraz.VectoCore.Utils;
namespace TUGraz.VectoCore.Tests.FileIO
{
[TestFixture]
public class VectoCSVFileTest
{
[OneTimeSetUp]
public void RunBeforeAnyTests()
{
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);
}
[Test]
public void VectoCSVFile_Read()
{
......
......@@ -35,13 +35,14 @@ using NUnit.Framework;
using TUGraz.VectoCommon.Utils;
using TUGraz.VectoCore.Models.Simulation.Data;
using TUGraz.VectoCore.Tests.Utils;
using System.IO;
namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
{
[TestFixture]
public class DriverStrategyTestCoachAux
{
[TestFixtureSetUp]
[OneTimeSetUp]
public void Init()
{
//LogManager.DisableLogging();
......@@ -58,6 +59,8 @@ namespace TUGraz.VectoCore.Tests.Integration.BusAuxiliaries
};
GraphWriter.Series1Label = "Vecto 3";
GraphWriter.Series2Label = "Vecto 2.0_aux";
Directory.SetCurrentDirectory(TestContext.CurrentContext.TestDirectory);
}
private static string GetSlopeString(double slope)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment