From 8e039c6ed6682c0e3096cd7ef17977635b006e2e Mon Sep 17 00:00:00 2001 From: Markus Quaritsch <markus.quaritsch@tugraz.at> Date: Tue, 21 Jun 2016 15:17:00 +0200 Subject: [PATCH] use si class in hvac constants, make it serializable; extend tests for aaux --- .../VectoAuxiliaries/Hvac/HVACConstants.vb | 18 ++++++++++++------ .../UnitTests/SSMTOOLTests.vb | 7 +++++-- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/VECTOAux/VectoAuxiliaries/Hvac/HVACConstants.vb b/VECTOAux/VectoAuxiliaries/Hvac/HVACConstants.vb index dbe43d9244..51fb227076 100644 --- a/VECTOAux/VectoAuxiliaries/Hvac/HVACConstants.vb +++ b/VECTOAux/VectoAuxiliaries/Hvac/HVACConstants.vb @@ -8,37 +8,43 @@ ' WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. ' ' See the LICENSE.txt for the specific language governing permissions and limitations. +Imports Newtonsoft.Json Imports TUGraz.VectoCommon.Utils Namespace Hvac Public Class HVACConstants Implements IHVACConstants - Private _fuelDensity As KilogramPerCubicMeter + <JsonProperty("FuelDensity")> ReadOnly _fuelDensity As Double + <JsonProperty("DieselGCVJperGram")> ReadOnly _dieselGcvJperGram As Double = 44800 Public Sub New() - _fuelDensity = 835.SI(Of KilogramPerCubicMeter)() + _fuelDensity = 835 '.SI(Of KilogramPerCubicMeter)() End Sub Public Sub New(fuelDensitySingle As KilogramPerCubicMeter) - _fuelDensity = fuelDensitySingle + _fuelDensity = fuelDensitySingle.Value() End Sub + + <JsonIgnore> Public ReadOnly Property DieselGCVJperGram As JoulePerKilogramm Implements IHVACConstants.DieselGCVJperGram Get - Return 44800.SI().Joule.Per.Gramm.Cast(Of JoulePerKilogramm)() + Return _dieselGcvJperGram.SI().Joule.Per.Gramm.Cast(Of JoulePerKilogramm)() End Get End Property + <JsonIgnore()> Public ReadOnly Property FuelDensity As KilogramPerCubicMeter Implements IHVACConstants.FuelDensity Get - Return _fuelDensity + Return _fuelDensity.SI(Of KilogramPerCubicMeter)() End Get End Property + <JsonIgnore()> Public ReadOnly Property FuelDensityAsGramPerLiter As Double Implements IHVACConstants.FuelDensityAsGramPerLiter Get - Return _fuelDensity.Value() * 1000 + Return _fuelDensity * 1000 End Get End Property End Class diff --git a/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb b/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb index 30dc6b4560..568ab56168 100644 --- a/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb +++ b/VECTOAux/VectoAuxiliariesTests/UnitTests/SSMTOOLTests.vb @@ -525,10 +525,12 @@ Namespace UnitTests Public Sub SaveAndRetreiveTest() Const filePath As String = "SSMTOOLTestSaveRetreive.json" + Dim success As Boolean Dim target As SSMTOOL = New SSMTOOL(filePath, New HVACConstants(), False, True) - target.Save(filePath) + success = target.Save(filePath) + Assert.IsTrue(success) 'change something target.GenInputs.BP_BusLength = 202.202 @@ -536,7 +538,8 @@ Namespace UnitTests Assert.AreEqual(target.GenInputs.BP_BusLength, 202.202) 'Retreive - target.Load(filePath) + success = target.Load(filePath) + Assert.IsTrue(success) Assert.AreEqual(target.GenInputs.BP_BusLength, 10.655) End Sub -- GitLab