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 }; var 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 = Serializable.Decode <BrowseResponse>(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(Property <byte[]> .Create( (uint)DnsRecordType.Txt, Encoding.UTF8.GetBytes("some test = test") )); response.Properties.Add(Property <byte[]> .Create( (uint)DnsRecordType.Txt, Encoding.UTF8.GetBytes("a record") )); response.Properties.Add(Property <byte[]> .Create( (uint)DnsRecordType.Txt, Encoding.UTF8.GetBytes("spasdfsdafsda") )); response.Properties.Add(Property <byte[]> .Create( (uint)DnsRecordType.Txt, Encoding.UTF8.GetBytes("asd=3433434") )); response.Properties.Add(Property <byte[]> .Create( (uint)DnsRecordType.Txt, Encoding.UTF8.GetBytes("FPOÜDFD") )); response.Properties.Add(Property <byte[]> .Create( (uint)DnsRecordType.Txt, Encoding.UTF8.GetBytes("some test = test") )); response.Properties.Add(Property <byte[]> .Create( (uint)DnsRecordType.Txt, Encoding.UTF8.GetBytes("a record") )); response.Properties.Add(Property <byte[]> .Create( (uint)DnsRecordType.Txt, Encoding.UTF8.GetBytes("spasdfsdafsda") )); response.Properties.Add(Property <byte[]> .Create( (uint)DnsRecordType.Txt, Encoding.UTF8.GetBytes("asd=3433434") )); response.Properties.Add(Property <byte[]> .Create( (uint)DnsRecordType.Txt, Encoding.UTF8.GetBytes("FPOÜDFD") )); var 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 = Serializable.Decode <BrowseResponse>(new MemoryStream(buf), CodecId.Mpack); // Assert Assert.IsTrue(response.Equals(returned)); }