diff --git a/tests/AVEVA.Historian.Client.Tests/HistorianClientIntegrationTests.cs b/tests/AVEVA.Historian.Client.Tests/HistorianClientIntegrationTests.cs index f906675..be7e6ac 100644 --- a/tests/AVEVA.Historian.Client.Tests/HistorianClientIntegrationTests.cs +++ b/tests/AVEVA.Historian.Client.Tests/HistorianClientIntegrationTests.cs @@ -211,7 +211,7 @@ public sealed class HistorianClientIntegrationTests } [Fact] - public async Task ReadEventsAsync_AgainstLocalHistorian_DoesNotThrow() + public async Task ReadEventsAsync_AgainstLocalHistorian_ReturnsWellFormedEvents() { string? host = Environment.GetEnvironmentVariable("HISTORIAN_HOST"); if (string.IsNullOrWhiteSpace(host) || !string.Equals(host, "localhost", StringComparison.OrdinalIgnoreCase) || !OperatingSystem.IsWindows()) @@ -227,18 +227,28 @@ public sealed class HistorianClientIntegrationTests }); DateTime endUtc = DateTime.UtcNow; - DateTime startUtc = endUtc - TimeSpan.FromDays(7); + DateTime startUtc = endUtc - TimeSpan.FromDays(30); - // The event-row WCF wire format is not yet decoded; this test verifies the chain - // (ValCl + Open2 + Retr.IsOriginalAllowed + Retr.StartEventQuery) reaches the server - // without throwing. An empty event list is acceptable until row parsing is wired. + // The full chain (ValCl + Open2 + Retr.IsOriginalAllowed + Retr.StartEventQuery + + // GetNextEventQueryResultBuffer + HistorianEventRowProtocol.Parse) returns real, parsed + // events. Requires the local store to hold events in the window — System-Platform + // alarm/user-write events are present on a working Historian. NOTE: enumeration currently + // stops at the first benign `type=4 code=85` soft-terminal, so this verifies parsing + // correctness rather than exhaustive retrieval (decoding code 85 to drain all rows is a + // separate capture task). List events = []; await foreach (AVEVA.Historian.Client.Models.HistorianEvent evt in client.ReadEventsAsync(startUtc, endUtc, CancellationToken.None)) { events.Add(evt); } - Assert.NotNull(events); + Assert.NotEmpty(events); + Assert.All(events, evt => + { + Assert.False(string.IsNullOrWhiteSpace(evt.Type)); // e.g. "User.Write", "Alarm.Set" + Assert.NotNull(evt.Properties); + Assert.InRange(evt.EventTimeUtc, startUtc - TimeSpan.FromDays(1), endUtc + TimeSpan.FromDays(1)); + }); } [Fact]