using Microsoft.Data.SqlClient.Server; using Shouldly; using Xunit; using ZB.MOM.WW.OtOpcUa.Core.Abstractions; using ZB.MOM.WW.OtOpcUa.Driver.Historian.Sql.Common; namespace ZB.MOM.WW.OtOpcUa.Driver.Historian.SqlServer.Tests; /// The TVP half of the mapper tests (the column round-trip half moved to Sql.Common.Tests). public sealed class SampleRowMapperTests { [Fact] public void Sample_records_keep_sub_millisecond_ticks() { var t = new DateTime(2026, 10, 9, 0, 0, 0, DateTimeKind.Utc).AddTicks(1234567); var rec = SampleRowMapper.ToSampleRecords([new HistorianSampleRow(t, HistorianValue.FromDouble(2), 0x80050000u)]).Single(); rec.GetDateTime(0).Ticks.ShouldBe(t.Ticks); rec.GetByte(1).ShouldBe((byte)1); rec.GetDouble(2).ShouldBe(2d); rec.IsDBNull(3).ShouldBeTrue(); rec.IsDBNull(4).ShouldBeTrue(); rec.GetInt32(5).ShouldBe(unchecked((int)0x80050000u)); } [Fact] public void Time_records_keep_sub_millisecond_ticks() { var t = new DateTime(2026, 10, 9, 0, 0, 0, DateTimeKind.Utc).AddTicks(1234567); SampleRowMapper.ToTimeRecords([t]).Single().GetDateTime(0).Ticks.ShouldBe(t.Ticks); } }