public void ShouldThrowExceptionIfSizeIsGreaterThanShortMax() { var packer = new PackStreamWriter(new MemoryStream()); var ex = Record.Exception(() => packer.WriteStructHeader(short.MaxValue + 1, 0x1)); ex.Should().BeOfType <ProtocolException>(); }
public void ShouldWriteStructHeaderCorrectly(int size, byte marker, byte[] expected) { var mocks = new WriterTests.Mocks(); var writer = new PackStreamWriter(mocks.OutputStream); writer.WriteStructHeader(size, 0x77); mocks.VerifyWrite(marker); mocks.VerifyWrite(expected); }
public void ShouldWriteStructHeaderStruct16Correctly() { var mocks = new WriterTests.Mocks(); var writer = new PackStreamWriter(mocks.OutputStream); writer.WriteStructHeader(short.MaxValue, 0x77); mocks.VerifyWrite(PackStream.Struct16); mocks.VerifyWrite(new byte[] { 0x7F, 0xFF }); mocks.VerifyWrite(0x77); }
private static byte[] CreateSuccessMessage() { var stream = new MemoryStream(); var writer = new PackStreamWriter(stream, null); writer.WriteStructHeader(1, PackStream.MsgSuccess); writer.WriteMapHeader(1); writer.Write("x"); writer.Write(1); return(CreateChunkedMessage(stream.ToArray())); }
private static byte[] CreateNodeMessage() { var stream = new MemoryStream(); var writer = new PackStreamWriter(stream, null); writer.WriteStructHeader(3, PackStream.Node); writer.Write(1L); writer.Write(new List <string> { "Label" }); writer.Write(new Dictionary <string, object>()); return(CreateChunkedMessage(stream.ToArray())); }