test: cover GAP-035 GAP-036 and DEC-20260814-04 regressions
This commit is contained in:
49
tests/NT8.Core.Tests/Adapters/SimpleORBNT8DefaultsTests.cs
Normal file
49
tests/NT8.Core.Tests/Adapters/SimpleORBNT8DefaultsTests.cs
Normal file
@@ -0,0 +1,49 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
|
||||
namespace NT8.Core.Tests.Adapters
|
||||
{
|
||||
[TestClass]
|
||||
public class SimpleORBNT8DefaultsTests
|
||||
{
|
||||
[TestMethod]
|
||||
public void SetDefaults_DirectionFlags_EnableLongAndShortTrades()
|
||||
{
|
||||
string source = File.ReadAllText(FindSourceFile());
|
||||
string setDefaults = ExtractSetDefaultsBlock(source);
|
||||
|
||||
Assert.IsTrue(setDefaults.Contains("EnableLongTrades = true;"), "SetDefaults must enable long trades by default.");
|
||||
Assert.IsTrue(setDefaults.Contains("EnableShortTrades = true;"), "SetDefaults must enable short trades by default per DEC-20260814-04.");
|
||||
Assert.IsFalse(setDefaults.Contains("EnableShortTrades = false;"), "SetDefaults must not disable short trades by default.");
|
||||
}
|
||||
|
||||
private static string FindSourceFile()
|
||||
{
|
||||
DirectoryInfo dir = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
|
||||
while (dir != null)
|
||||
{
|
||||
string candidate = Path.Combine(dir.FullName, "src", "NT8.Adapters", "Strategies", "SimpleORBNT8.cs");
|
||||
if (File.Exists(candidate))
|
||||
return candidate;
|
||||
dir = dir.Parent;
|
||||
}
|
||||
|
||||
throw new FileNotFoundException("Could not locate src\\NT8.Adapters\\Strategies\\SimpleORBNT8.cs from test output directory.");
|
||||
}
|
||||
|
||||
private static string ExtractSetDefaultsBlock(string source)
|
||||
{
|
||||
const string marker = "if (State == State.SetDefaults)";
|
||||
int start = source.IndexOf(marker, StringComparison.Ordinal);
|
||||
if (start < 0)
|
||||
Assert.Fail("SimpleORBNT8.cs does not contain the SetDefaults state block.");
|
||||
|
||||
int end = source.IndexOf("else if (State == State.Configure)", start, StringComparison.Ordinal);
|
||||
if (end < 0)
|
||||
Assert.Fail("SimpleORBNT8.cs does not contain the Configure state block after SetDefaults.");
|
||||
|
||||
return source.Substring(start, end - start);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user