32f26272ae
Five tools under one repo, all docs organized per DOCS-GUIDE.md: - aalogcli: .NET 4.8 / x86 CliFx CLI for reading System Platform binary logs (*.aaLGX) for LLM debugging, built on aaOpenSource/aaLog. Commands: last, tail, range, unread, fields. Stable JSON envelope under --llm-json. Build template under lib/build/ for rebuilding aaLogReader.dll. - aot: ArchestrA Object Toolkit 2014 v4.0 reference material. Dev guide (Markdown converted from CHM), API reference for the ArchestrA.Toolkit namespace, and the Monitor / Watchdog VS sample solutions. - graccesscli: .NET 4.8 / x86 CliFx CLI that automates Galaxy configuration via the ArchestrA GRAccess COM interop. Includes session daemon, IPC protocol, and llm-json envelope contract. - grdb: SQL/DDL exploration of the Galaxy Repository database. DDL captures, reusable queries, hierarchy / contained-name <-> tag-name translation notes. - histdb: LLM-oriented reference for AVEVA Historian retrieval. INSQL linked-server, extension tables, every wwXxx time-domain extension, every retrieval mode, alarm/event SQL recipes, REST API. Distilled from the 243-page Historian Retrieval Guide. Root contains: - CLAUDE.md: thin index pointing into each tool's README. - DOCS-GUIDE.md: doctrine for organizing docs for LLM consumption. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
111 lines
2.9 KiB
C#
111 lines
2.9 KiB
C#
using System;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using Shouldly;
|
|
using Xunit;
|
|
using ZB.MOM.WW.GRAccess.Cli.Session;
|
|
|
|
namespace ZB.MOM.WW.GRAccess.Cli.Tests.Session
|
|
{
|
|
public class StaComThreadTests : IDisposable
|
|
{
|
|
private readonly StaComThread _sut;
|
|
|
|
public StaComThreadTests()
|
|
{
|
|
_sut = new StaComThread();
|
|
_sut.Start();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_sut.Dispose();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task RunAsync_ExecutesOnStaThread()
|
|
{
|
|
var apartmentState = await _sut.RunAsync(() => Thread.CurrentThread.GetApartmentState());
|
|
|
|
apartmentState.ShouldBe(ApartmentState.STA);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task RunAsync_ReturnsResult()
|
|
{
|
|
var result = await _sut.RunAsync(() => 42);
|
|
|
|
result.ShouldBe(42);
|
|
}
|
|
|
|
[Fact]
|
|
public async Task RunAsync_PropagatesException()
|
|
{
|
|
var ex = await Should.ThrowAsync<InvalidOperationException>(
|
|
_sut.RunAsync<int>(() => throw new InvalidOperationException("test error")));
|
|
|
|
ex.Message.ShouldBe("test error");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task RunAsync_VoidAction_Completes()
|
|
{
|
|
var executed = false;
|
|
|
|
await _sut.RunAsync(() => { executed = true; });
|
|
|
|
executed.ShouldBeTrue();
|
|
}
|
|
|
|
[Fact]
|
|
public async Task RunAsync_VoidAction_PropagatesException()
|
|
{
|
|
var ex = await Should.ThrowAsync<InvalidOperationException>(
|
|
_sut.RunAsync(() => throw new InvalidOperationException("void error")));
|
|
|
|
ex.Message.ShouldBe("void error");
|
|
}
|
|
|
|
[Fact]
|
|
public async Task RunAsync_MultipleWorkItems_ExecuteInOrder()
|
|
{
|
|
var results = new int[3];
|
|
|
|
await _sut.RunAsync(() => { results[0] = 1; });
|
|
await _sut.RunAsync(() => { results[1] = 2; });
|
|
await _sut.RunAsync(() => { results[2] = 3; });
|
|
|
|
results.ShouldBe(new[] { 1, 2, 3 });
|
|
}
|
|
|
|
[Fact]
|
|
public async Task RunAsync_AllWorkRunsOnSameThread()
|
|
{
|
|
var threadId1 = await _sut.RunAsync(() => Thread.CurrentThread.ManagedThreadId);
|
|
var threadId2 = await _sut.RunAsync(() => Thread.CurrentThread.ManagedThreadId);
|
|
|
|
threadId1.ShouldBe(threadId2);
|
|
}
|
|
|
|
[Fact]
|
|
public void Dispose_CanBeCalledMultipleTimes()
|
|
{
|
|
var thread = new StaComThread();
|
|
thread.Start();
|
|
thread.Dispose();
|
|
|
|
Should.NotThrow(() => thread.Dispose());
|
|
}
|
|
|
|
[Fact]
|
|
public void RunAsync_AfterDispose_ThrowsObjectDisposed()
|
|
{
|
|
var thread = new StaComThread();
|
|
thread.Start();
|
|
thread.Dispose();
|
|
|
|
Should.Throw<ObjectDisposedException>(() => thread.RunAsync(() => { }));
|
|
}
|
|
}
|
|
}
|