Skip to content

Commit

Permalink
refactored jsonPanels to be an attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Tom-Kingstone committed Oct 30, 2023
1 parent 404b1ab commit ee2cae6
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions .ci/unit-tests/XML_Adapter_Tests/PushTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class PushTests
XMLAdapter m_adapter;
XMLConfig m_config;
List<IBHoMObject> m_jsonObjects;
List<Panel> m_jsonPanels;

[OneTimeSetUp]
public void OneTimeSetUp()
Expand All @@ -38,6 +39,7 @@ public void OneTimeSetUp()
File = new FileSettings() { Directory = ModelsPath, FileName = "PushedModel.xml"},
};
m_jsonObjects = BH.Engine.Adapters.File.Compute.ReadFromJsonFile(Path.Combine(ModelsPath, "TestModel.json"), true).Cast<IBHoMObject>().ToList();
m_jsonPanels = BH.Engine.Environment.Query.Panels(m_jsonObjects);
}

[SetUp]
Expand Down Expand Up @@ -78,12 +80,11 @@ public void PushGBXML()
List<IBHoMObject> objs = m_adapter.Pull(request, actionConfig: m_config).Cast<IBHoMObject>().ToList();

List<Panel> pulledPanels = BH.Engine.Environment.Query.Panels(objs);
List<Panel> jsonPanels = BH.Engine.Environment.Query.Panels(m_jsonObjects);
List<Construction> constructions = objs.Where(x => x.GetType() == typeof(Construction)).Cast<Construction>().ToList();
List<Construction> jsonConstructions = m_jsonObjects.Where(x => x.GetType() == typeof(Construction) && x.Name == "generic_construction").Cast<Construction>().ToList();

pulledPanels = BH.Engine.Data.Query.OrderBy(pulledPanels, "Name");
jsonPanels = BH.Engine.Data.Query.OrderBy(jsonPanels, "Name");
List<Panel> jsonPanels = BH.Engine.Data.Query.OrderBy(m_jsonPanels, "Name");

//assert correct values
pulledPanels.Count.Should().Be(jsonPanels.Count, "There was a different number of panels pushed then pulled compared to expected.");
Expand Down Expand Up @@ -114,11 +115,10 @@ public void PushGBXMLNoConstructions()
List<IBHoMObject> objs = m_adapter.Pull(request, actionConfig: m_config).Cast<IBHoMObject>().ToList();

List<Panel> pulledPanels = BH.Engine.Environment.Query.Panels(objs);
List<Panel> jsonPanels = BH.Engine.Environment.Query.Panels(m_jsonObjects);
List<Construction> constructions = objs.Where(x => x.GetType() == typeof(Construction)).Cast<Construction>().ToList();

pulledPanels = BH.Engine.Data.Query.OrderBy(pulledPanels, "Name");
jsonPanels = BH.Engine.Data.Query.OrderBy(jsonPanels, "Name");
List<Panel> jsonPanels = BH.Engine.Data.Query.OrderBy(m_jsonPanels, "Name");

//assert correct values
pulledPanels.Count.Should().Be(jsonPanels.Count, "There was a different number of panels pushed then pulled compared to expected.");
Expand All @@ -144,16 +144,17 @@ public void PushGBXMLBuildingShell()
};
FilterRequest request = new FilterRequest();

//push, then pull objects
m_adapter.Push(m_jsonObjects, actionConfig: m_config);
List<IBHoMObject> objs = m_adapter.Pull(request, actionConfig: m_config).Cast<IBHoMObject>().ToList();

List<Panel> pulledPanels = BH.Engine.Environment.Query.Panels(objs);
List<Panel> jsonPanels = BH.Engine.Environment.Query.Panels(m_jsonObjects); //perhaps refactor to be m_jsonPanels
List<Construction> constructions = objs.Where(x => x.GetType() == typeof(Construction)).Cast<Construction>().ToList();

pulledPanels = BH.Engine.Data.Query.OrderBy(pulledPanels, "Name");
jsonPanels = BH.Engine.Data.Query.OrderBy(jsonPanels.ToSpaces().ExternalElements(), "Name");
List<Panel> jsonPanels = BH.Engine.Data.Query.OrderBy(m_jsonPanels.ToSpaces().ExternalElements(), "Name");

//assert correct values
pulledPanels.Count.Should().Be(jsonPanels.Count, "There was a different number of external panels pulled compared to expected.");
for (int i = 0; i < jsonPanels.Count; i++)
{
Expand Down

0 comments on commit ee2cae6

Please sign in to comment.