11b703708c
Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
34 lines
1.4 KiB
C#
34 lines
1.4 KiB
C#
using Shouldly;
|
|
using Xunit;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.QuestDb.Tests;
|
|
|
|
public sealed class QuestDbWalVisibilityTests
|
|
{
|
|
[Fact]
|
|
public async Task Timeout_zero_skips_the_wait_without_touching_the_database()
|
|
{
|
|
// Port 1 refuses connections: any attempt to query would throw, so returning true proves nothing was opened.
|
|
var conn = new QuestDbConnection(new QuestDbHistorianOptions { ConnectionString = "Host=127.0.0.1;Port=1;Timeout=1" });
|
|
var wal = new QuestDbWalVisibility(conn, TimeSpan.Zero);
|
|
wal.Disabled.ShouldBeTrue();
|
|
(await wal.WaitAsync("hist_sample", CancellationToken.None)).ShouldBeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task A_positive_timeout_does_touch_the_database_control()
|
|
{
|
|
var conn = new QuestDbConnection(new QuestDbHistorianOptions { ConnectionString = "Host=127.0.0.1;Port=1;Timeout=1" });
|
|
var wal = new QuestDbWalVisibility(conn, TimeSpan.FromSeconds(1));
|
|
wal.Disabled.ShouldBeFalse();
|
|
await Should.ThrowAsync<Exception>(() => wal.WaitAsync("hist_sample", CancellationToken.None));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(5, 5, true)]
|
|
[InlineData(6, 5, true)]
|
|
[InlineData(4, 5, false)]
|
|
public void Reached_is_writerTxn_at_or_beyond_the_target(long writer, long target, bool expected) =>
|
|
QuestDbWalVisibility.Reached(writer, target).ShouldBe(expected);
|
|
}
|