Exemple #1
0
        public void TestJsonLinkResponseWriteRead()
        {
            // Arrange
            Inet4SocketAddress sal = new Inet4SocketAddress(0xffaabbcc, 9643);
            var ab = new byte[16];

            new Random().NextBytes(ab);
            Inet6SocketAddress sap = new Inet6SocketAddress(ab, 443, 1, 0);

            LinkResponse args = new LinkResponse();

            args.LocalAddress = sal;
            args.PeerAddress  = sap;
            args.LinkId       = new Reference();

            Message      response = new Message(null, null, null, args);
            MemoryStream stream   = new MemoryStream();

            // Act
            response.Encode(stream, CodecId.Json);
            byte[]  buf      = Interop.MessageDecodeEncode(CodecId.Json, 1, stream.GetBuffer(), stream.Length, buffer, buffer.Length);
            Message returned = Message.Decode(new MemoryStream(buf), CodecId.Json);

            // Assert
            Assert.IsTrue(response.Equals(returned));
        }
        public void TestJsonLinkResponseWriteRead()
        {
            // Arrange
            var sal = new Inet4SocketAddress(0xffaabbcc, 9643);
            var ab  = new byte[16];

            new Random().NextBytes(ab);
            var sap = new Inet6SocketAddress(ab, 443, 1, 0);

            var args     = LinkResponse.Create(new Reference(), sal, sap, 0x18);
            var response = Message.Create(null, null, null, args);
            var stream   = new MemoryStream();

            // Act
            response.Encode(stream, CodecId.Json);
            byte[] buf      = Interop.MessageDecodeEncode(CodecId.Json, 1, stream.GetBuffer(), stream.Length, buffer, buffer.Length);
            var    returned = Serializable.Decode <Message>(new MemoryStream(buf), CodecId.Json);

            // Assert
            Assert.IsTrue(response.Equals(returned));
        }