public void TestJsonBrowseResponseWriteRead2() { // Arrange var response = new BrowseResponse { Flags = 0, Handle = new Reference(), Item = new ProxySocketAddress { Flags = 1, Port = 1, Host = "/test/test/test" }, Error = 0 }; MemoryStream stream = new MemoryStream(); // Act response.Encode(stream, CodecId.Json); byte[] buf = Interop.TypeDecodeEncode(CodecId.Json, BrowseResponseType, stream.GetBuffer(), stream.Length, buffer, buffer.Length); var returned = BrowseResponse.Decode(new MemoryStream(buf), CodecId.Json); // Assert Assert.IsTrue(response.Equals(returned)); }
public void TestMpackBrowseResponseWriteRead1() { // Arrange var response = new BrowseResponse { Flags = 0, Handle = new Reference(), Item = new ProxySocketAddress { Flags = 1, Port = 1, Host = "test._test._tcp.longdomain12345" }, Error = 0 }; response.Properties.Add(new Property <byte[]> { Type = (uint)DnsRecordType.Txt, Value = Encoding.UTF8.GetBytes("some test = test") }); response.Properties.Add(new Property <byte[]> { Type = (uint)DnsRecordType.Txt, Value = Encoding.UTF8.GetBytes("a record") }); response.Properties.Add(new Property <byte[]> { Type = (uint)DnsRecordType.Txt, Value = Encoding.UTF8.GetBytes("spasdfsdafsda") }); response.Properties.Add(new Property <byte[]> { Type = (uint)DnsRecordType.Txt, Value = Encoding.UTF8.GetBytes("asd=3433434") }); response.Properties.Add(new Property <byte[]> { Type = (uint)DnsRecordType.Txt, Value = Encoding.UTF8.GetBytes("FPOÜDFD") }); response.Properties.Add(new Property <byte[]> { Type = (uint)DnsRecordType.Txt, Value = Encoding.UTF8.GetBytes("some test = test") }); response.Properties.Add(new Property <byte[]> { Type = (uint)DnsRecordType.Txt, Value = Encoding.UTF8.GetBytes("a record") }); response.Properties.Add(new Property <byte[]> { Type = (uint)DnsRecordType.Txt, Value = Encoding.UTF8.GetBytes("spasdfsdafsda") }); response.Properties.Add(new Property <byte[]> { Type = (uint)DnsRecordType.Txt, Value = Encoding.UTF8.GetBytes("asd=3433434") }); response.Properties.Add(new Property <byte[]> { Type = (uint)DnsRecordType.Txt, Value = Encoding.UTF8.GetBytes("FPOÜDFD") }); MemoryStream stream = new MemoryStream(); // Act response.Encode(stream, CodecId.Mpack); byte[] buf = Interop.TypeDecodeEncode(CodecId.Mpack, BrowseResponseType, stream.GetBuffer(), stream.Length, buffer, buffer.Length); var returned = BrowseResponse.Decode(new MemoryStream(buf), CodecId.Mpack); // Assert Assert.IsTrue(response.Equals(returned)); }