using Shouldly; using Xunit; using ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport.Wire; namespace ZB.MOM.WW.OtOpcUa.Driver.Ab.Transport.Tests.Wire; public sealed class CipWriterTests { [Fact] public void PatchU16_overwrites_an_already_written_word() { var w = new CipWriter().U16(0).U8(7); w.PatchU16(0, 0xABCD); w.ToArray().ShouldBe(new byte[] { 0xCD, 0xAB, 0x07 }); } [Theory] [InlineData(-1)] [InlineData(2)] // would straddle the end: only bytes 0..2 are written [InlineData(3)] [InlineData(100)] // inside spare buffer capacity (256), but never written public void PatchU16_outside_the_written_range_throws(int offset) { var w = new CipWriter().U16(0).U8(7); Should.Throw(() => w.PatchU16(offset, 1)); w.ToArray().ShouldBe(new byte[] { 0, 0, 7 }); // nothing was patched } }