Beispiel #1
0
        public void ProtocolMessageDao_ProtocolMessage_Should_Be_Convertible()
        {
            var newGuid  = Guid.NewGuid();
            var peerId   = PeerIdHelper.GetPeerId("testcontent");
            var original = new ProtocolMessage
            {
                CorrelationId = newGuid.ToByteString(),
                TypeUrl       = "cleanurl",
                Value         = "somecontent".ToUtf8ByteString(),
                PeerId        = peerId
            };

            var messageDao = original.ToDao <ProtocolMessage, ProtocolMessageDao>(_mapperProvider);

            messageDao.TypeUrl.Should().Be("cleanurl");
            messageDao.CorrelationId.Should().Be(newGuid.ToString());
            messageDao.PeerId.Port.Should().Be((ushort)peerId.Port);
            messageDao.PeerId.Ip.Should().Be(new IPAddress(peerId.Ip.ToByteArray()).MapToIPv6().ToString());

            var reconverted = messageDao.ToProtoBuff <ProtocolMessageDao, ProtocolMessage>(_mapperProvider);

            reconverted.Should().Be(original);
        }