Skip to content

Commit

Permalink
test(*): add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
MingboPeng committed Feb 7, 2024
1 parent 86c69a2 commit 3c0c696
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 0 deletions.
44 changes: 44 additions & 0 deletions src/Ironbug.HVAC_Tests/00_DummyTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,49 @@ namespace Ironbug.HVACTests
{
public class DummyTest
{
[Test]
public void DummyTest_CAD_Id()
{
var model = new Model();
var obj = new OpenStudio.CoilHeatingElectric(model);
obj.setCADObjectId("CAD ID");
var cadID = obj.cadObjectId().get();
Assert.AreEqual("CAD ID", cadID);

var tempFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "cadID.osm");
model.Save(tempFile);
}


[Test]
public void DummyTest_DOAS()
{
var model = new OpenStudio.Model();
var airloop = new OpenStudio.AirLoopHVAC(model);

var oaControler = new OpenStudio.ControllerOutdoorAir(model);
var oa = new OpenStudio.AirLoopHVACOutdoorAirSystem(model, oaControler);
var doas = new OpenStudio.AirLoopHVACDedicatedOutdoorAirSystem(oa);
doas.addAirLoop(airloop);

var tempFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "doas.osm");
model.Save(tempFile);


}

[Test]
public void DummyTest_ProfilePlant()
{
var model = new OpenStudio.Model();
var loop = new OpenStudio.PlantLoop(model);
var load = new OpenStudio.LoadProfilePlant(model);
//load.addToNode
loop.addDemandBranchForComponent(load);
var tempFile = System.IO.Path.Combine(System.IO.Path.GetTempPath(), "profileLoad.osm");
model.Save(tempFile);
}

[Test]
public void DummyTest_OS_Coil_Heating_WaterFields()
{
Expand Down Expand Up @@ -570,5 +613,6 @@ private void AddCentralAirSouceHeatPump(Model model, PlantLoop hotwaterPlant)




}
}
62 changes: 62 additions & 0 deletions src/Ironbug.HVAC_Tests/RecreateFromTemplates.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using System;
using System.IO;
using System.Linq;
using Ironbug.HVAC;
using NUnit.Framework;

namespace Ironbug.HVACTests
{

public class RecreateFromTemplates
{
[Test]
public void UnitHeaterDuplicateTest()
{
var coil = new IB_CoilHeatingElectric();
var unitHeater = new IB_ZoneHVACUnitHeater();
unitHeater.SetHeatingCoil(coil);

var dupCount = 2;
var dups = unitHeater.Duplicate(dupCount);
Assert.AreEqual(dupCount, dups.Count);
var dupIds = dups.Select(_=>_.GetTrackingID()).Distinct();
Assert.AreEqual(dupCount, dupIds.Count());


// ensure each unit heater has their own heating coil
var dupCoils = dups.Select(_ => _.Children.FirstOrDefault());
Assert.AreEqual(dupCount, dupCoils.Count());
var dupCoilIds = dupCoils.Select(_ => _.GetTrackingID()).Distinct();
Assert.AreEqual(dupCount, dupCoilIds.Count());

}

//[Test]
//public void UnitHeaterHWTest()
//{
// var folder = Path.Combine( TestHelper.TestSourceFolder, "Compiling templates");
// //var files = Directory.GetFiles(folder);
// //var jsons = files.Where(_ => _.EndsWith(".json"));

// //D:\Dev\Ironbug\src\Ironbug.HVAC_Tests\TestSource\Compiling templates
// var jsonPath = Path.Combine(folder, "UnitHeaterHW.json");
// var sysJson = File.ReadAllText(jsonPath);
// var system = IB_HVACSystem.FromJson(sysJson);


// //foreach (var hvac in jsons)
// //{
// // var fileName = Path.GetFileNameWithoutExtension(hvac);
// // Console.WriteLine($"Testing {fileName}");
// // var saveAsOsm = Path.Combine(Path.GetTempPath(), $"{fileName}.osm");
// // File.Copy(osm, saveAsOsm, true);
// // var done = IB_HVACSystem.SaveHVAC(saveAsOsm, hvac);
// // if (!done)
// // Console.WriteLine($"Failed to save {hvac}");
// // Assert.True(done);

// //}

//}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"$type":"Ironbug.HVAC.IB_HVACSystem, Ironbug.HVAC","DisplayName":null,"AirLoops":[{"$type":"Ironbug.HVAC.IB_NoAirLoop, Ironbug.HVAC","ThermalZones":[{"$type":"Ironbug.HVAC.BaseClass.IB_ThermalZone, Ironbug.HVAC","AirTerminal":{"$type":"Ironbug.HVAC.IB_AirTerminalSingleDuctConstantVolumeNoReheat, Ironbug.HVAC","CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[cbb6bf09]"}]},"ZoneEquipments":[{"$type":"Ironbug.HVAC.IB_ZoneHVACUnitHeater, Ironbug.HVAC","Children":[{"$type":"Ironbug.HVAC.IB_CoilHeatingWater, Ironbug.HVAC","CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[a9bb1f11]"}]},{"$type":"Ironbug.HVAC.IB_FanConstantVolume, Ironbug.HVAC","CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[c5b9bbcd]"}]}],"CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[d9a9cada]"}]}],"SizingZone":{"$type":"Ironbug.HVAC.IB_SizingZone, Ironbug.HVAC","CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[b8d90f24]"}]},"CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[c522ccdd]"},{"Field":{"FullName":"Name","DataTypeName":"System.String"},"Value":"dummyZone"}],"IBProperties":{"$type":"Ironbug.HVAC.BaseClass.IB_PropArgumentSet, Ironbug.HVAC","IsAirTerminalBeforeZoneEquipments":true}}],"SizingSystem":{"$type":"Ironbug.HVAC.IB_SizingSystem, Ironbug.HVAC","CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[415621cd]"}]},"SupplyComponents":[],"DemandComponents":[],"CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[5f256185]"}]}],"PlantLoops":[{"$type":"Ironbug.HVAC.IB_PlantLoop, Ironbug.HVAC","SizingPlant":{"$type":"Ironbug.HVAC.IB_SizingPlant, Ironbug.HVAC","CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[40e0a731]"},{"Field":{"FullName":"LoopType","DataTypeName":"System.String"},"Value":"Heating"}]},"OperationScheme":null,"SupplyComponents":[{"$type":"Ironbug.HVAC.IB_PlantLoopBranches, Ironbug.HVAC","Branches":[[{"$type":"Ironbug.HVAC.IB_BoilerHotWater, Ironbug.HVAC","CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[6aea06d2]"}]}]],"CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[12765646]"}]}],"DemandComponents":[{"$type":"Ironbug.HVAC.IB_PlantLoopBranches, Ironbug.HVAC","Branches":[[{"$type":"Ironbug.HVAC.IB_CoilHeatingWater, Ironbug.HVAC","CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[a9bb1f11]"}]}]],"CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[e45b347b]"}]}],"CustomAttributes":[{"Field":{"FullName":"Comment","DataTypeName":"System.String"},"Value":"TrackingID:#[864d736c]"},{"Field":{"FullName":"Name","DataTypeName":"System.String"},"Value":"Hot Water Loop"},{"Field":{"FullName":"FluidType","DataTypeName":"System.String"},"Value":"Water"}]}],"IBVersion":"1.12.2.0"}

0 comments on commit 3c0c696

Please sign in to comment.