Skip to content

Commit 1d0c898

Browse files
committed
Add logging of BHoM events to Unit tests
1 parent 5f716e0 commit 1d0c898

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

.ci/unit-tests/Robot_Adapter_Tests/PullTests.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
using BH.oM.Analytical.Results;
3636
using System;
3737
using Shouldly;
38+
using BH.oM.Adapter.Commands;
3839

3940
namespace BH.Tests.Adapter.Robot
4041
{
@@ -52,6 +53,26 @@ public void OneTimeSetup()
5253
m_Adapter = new RobotAdapter(modelPath, null, true);
5354
}
5455

56+
[SetUp]
57+
public void Setup()
58+
{
59+
BH.Engine.Base.Compute.ClearCurrentEvents();
60+
}
61+
62+
[TearDown]
63+
public void TearDown()
64+
{
65+
var events = BH.Engine.Base.Query.CurrentEvents();
66+
if (events.Any())
67+
{
68+
Console.WriteLine("BHoM events raised during execution:");
69+
foreach (var ev in events)
70+
{
71+
Console.WriteLine($"{ev.Type}: {ev.Message}");
72+
}
73+
}
74+
}
75+
5576
[Test]
5677
public void PullBarsWithTag()
5778
{

.ci/unit-tests/Robot_Adapter_Tests/PushTests.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,22 @@ public void OntimeSetup()
5555
public void Setup()
5656
{
5757
m_Adapter.Execute(new NewModel());
58+
BH.Engine.Base.Compute.ClearCurrentEvents();
5859
}
5960

6061
[TearDown]
6162
public void TearDown()
6263
{
6364
m_Adapter.Execute(new Close { SaveBeforeClose = false });
65+
var events = BH.Engine.Base.Query.CurrentEvents();
66+
if (events.Any())
67+
{
68+
Console.WriteLine("BHoM events raised during execution:");
69+
foreach (var ev in events)
70+
{
71+
Console.WriteLine($"{ev.Type}: {ev.Message}");
72+
}
73+
}
6474
}
6575

6676
[Test]
@@ -110,7 +120,6 @@ public void PushBarsWithTag()
110120
bar.Tags.ShouldContain(tag);
111121
}
112122
}
113-
114123
}
115124

116125
[Test]

0 commit comments

Comments
 (0)