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

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

testing vehiclecontainer

parent 14205221
No related branches found
No related tags found
No related merge requests found
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using TUGraz.VectoCore.Models.SimulationComponent;
namespace TUGraz.VectoCore.Models.Simulation
{
public class SimulationContainer
{
private IList<VectoSimulationComponent> _components = new List<VectoSimulationComponent>();
private ICombustionEngine _engine = null;
private IGearbox _gearbox = null;
public void AddComponent(VectoSimulationComponent component)
{
DoAddComponent(component);
}
public void Addcomponent<T>(T engine) where T : VectoSimulationComponent, ICombustionEngine
{
_engine = engine;
DoAddComponent(engine);
}
public void AddComponent<T>(T gearbox) where T : VectoSimulationComponent, IGearbox
{
_gearbox = gearbox;
DoAddComponent(gearbox);
}
public IReadOnlyCollection<VectoSimulationComponent> SimulationComponents()
{
return new ReadOnlyCollection<VectoSimulationComponent>(_components);
}
public ICombustionEngine CombustionEngine()
{
return _engine;
}
public IGearbox Gearbox()
{
return _gearbox;
}
protected void DoAddComponent(VectoSimulationComponent component)
{
_components.Add(component);
}
}
}
......@@ -164,7 +164,7 @@ namespace TUGraz.VectoCore.Models.SimulationComponent.Impl
{
var deltaEngineSpeed = engineSpeed - _previousState.EngineSpeed;
var avgEngineSpeed = (_previousState.EngineSpeed + engineSpeed) / 2.0;
return _data.Inertia*VectoMath.RpmTpAngularVelocity(deltaEngineSpeed)*VectoMath.RpmTpAngularVelocity(avgEngineSpeed);
return _data.Inertia * VectoMath.RpmTpAngularVelocity(deltaEngineSpeed) * VectoMath.RpmTpAngularVelocity(avgEngineSpeed);
}
// accelleration los rotation engine
......
......@@ -84,6 +84,7 @@
<Compile Include="Models\SimulationComponent\IWheels.cs" />
<Compile Include="Models\SimulationComponent\SimulationComponentData.cs" />
<Compile Include="Models\SimulationComponent\VectoSimulationComponent.cs" />
<Compile Include="Models\Simulation\SimulationContainer.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Utils\DataRowExtensionMethods.cs" />
<Compile Include="Utils\VectoMath.cs" />
......
using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using TUGraz.VectoCore.Models.Simulation;
using TUGraz.VectoCore.Models.SimulationComponent;
using TUGraz.VectoCore.Models.SimulationComponent.Data;
using TUGraz.VectoCore.Models.SimulationComponent.Impl;
namespace TUGraz.VectoCore.Tests.Models
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
var engine = new CombustionEngine(new CombustionEngineData());
var simulationcontainer = new SimulationContainer();
simulationcontainer.Addcomponent(engine);
Assert.IsInstanceOfType(simulationcontainer.CombustionEngine(), typeof(ICombustionEngine));
}
}
}
......@@ -69,6 +69,7 @@
<ItemGroup>
<Compile Include="Models\SimulationComponentData\FullLoadCurveTest.cs" />
<Compile Include="Models\SimulationComponent\CombustionEngineTest.cs" />
<Compile Include="Models\UnitTest1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
......
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