50 lines
2.1 KiB
C#
50 lines
2.1 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|