-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSubTest.cs
More file actions
50 lines (46 loc) · 1.47 KB
/
SubTest.cs
File metadata and controls
50 lines (46 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using NinjaTrader.Cbi;
using System;
using System.Collections.Generic;
namespace NinjaTrader.UnitTest
{
public class SubTest : IDisposable
{
private string testCase;
private string msg;
private Dictionary<string, object> parameters;
private bool success = true;
public SubTest(string testCase, string msg = null, Dictionary<string, object> parameters = null)
{
this.testCase = testCase;
this.msg = msg;
this.parameters = parameters ?? new Dictionary<string, object>();
}
public void Dispose()
{
try
{
// Execute the test case
//testCase.Run();
// Set the success flag to true if execution does not throw an exception
success = true;
}
catch (Exception)
{
// Set the success flag to false if an exception is encountered
success = false;
throw; // re-throw the exception to signal test failure
}
finally
{
if (success)
{
NinjaTrader.NinjaScript.NinjaScript.Log($"{testCase} ({msg})", LogLevel.Information);
}
else
{
NinjaTrader.NinjaScript.NinjaScript.Log($"{testCase} ({msg}) ... FAIL", LogLevel.Error);
}
}
}
}
}