protected void TestWriteMessages(ProtocolTestData testData) { var bytes = Write(testData.Message); // Unframe the message to check the binary encoding var byteSpan = new ReadOnlySequence <byte>(bytes); Assert.True(BinaryMessageParser.TryParseMessage(ref byteSpan, out var unframed)); // Check the baseline binary encoding, use Assert.True in order to configure the error message var actual = Convert.ToBase64String(unframed.ToArray()); Assert.True(string.Equals(actual, testData.Binary, StringComparison.Ordinal), $"Binary encoding changed from{Environment.NewLine} [{testData.Binary}]{Environment.NewLine} to{Environment.NewLine} [{actual}]{Environment.NewLine}Please verify the MsgPack output and update the baseline"); }
protected void TestParseMessages(ProtocolTestData testData) { // Verify that the input binary string decodes to the expected MsgPack primitives var bytes = Convert.FromBase64String(testData.Binary); // Parse the input fully now. bytes = Frame(bytes); var data = new ReadOnlySequence <byte>(bytes); Assert.True(HubProtocol.TryParseMessage(ref data, new TestBinder(testData.Message), out var message)); Assert.NotNull(message); Assert.Equal(testData.Message, message, TestHubMessageEqualityComparer.Instance); }