cs-codex-dist-tests/Tests/CodexTests/AutoBootstrapDistTest.cs

47 lines
1.2 KiB
C#
Raw Permalink Normal View History

2023-09-12 13:43:30 +00:00
using CodexPlugin;
using DistTestCore;
2023-09-12 13:43:30 +00:00
using NUnit.Framework;
namespace CodexTests
2023-09-12 13:43:30 +00:00
{
2023-09-13 12:24:43 +00:00
public class AutoBootstrapDistTest : CodexDistTest
2023-09-12 13:43:30 +00:00
{
private readonly Dictionary<TestLifecycle, ICodexNode> bootstrapNodes = new Dictionary<TestLifecycle, ICodexNode>();
2023-09-13 12:24:43 +00:00
[SetUp]
public void SetUpBootstrapNode()
2023-09-12 13:43:30 +00:00
{
var tl = Get();
if (!bootstrapNodes.ContainsKey(tl))
{
bootstrapNodes.Add(tl, StartCodex(s => s.WithName("BOOTSTRAP_" + tl.TestNamespace)));
}
2023-09-12 13:43:30 +00:00
}
[TearDown]
public void TearDownBootstrapNode()
{
bootstrapNodes.Remove(Get());
}
2023-09-13 12:24:43 +00:00
protected override void OnCodexSetup(ICodexSetup setup)
2023-09-12 13:43:30 +00:00
{
var node = BootstrapNode;
if (node != null) setup.WithBootstrapNode(node);
2023-09-12 13:43:30 +00:00
}
protected ICodexNode? BootstrapNode
{
get
{
var tl = Get();
if (bootstrapNodes.TryGetValue(tl, out var node))
{
return node;
}
return null;
}
}
2023-09-12 13:43:30 +00:00
}
}