コード例 #1
0
        public void LookupMessageSerializationTest()
        {
            var om = new LookupMessage(HostName, ProtoFlags, true, InterfaceIndex);

            var message = ServiceMessageTestHelper.SerializeDeserializeTest(om);

            message.Payload.HostName.Should().Be(HostName);
            message.Payload.ProtocolFlags.Should().Be(ProtoFlags);
            message.Payload.Flags.Should().Be(Flags);
            message.Payload.InterfaceIndex.Should().Be(InterfaceIndex);
        }
コード例 #2
0
        public void TestMessageFieldUpperBounds()
        {
            var body = new byte[255];

            for (var i = 0; i < body.Length; ++i)
            {
                body[i] = (byte)i;
            }

            var getChunkMsg  = new GetChunkMessage(9, 9, FileId1, 999999);
            var bytes        = getChunkMsg.Serialize();
            var getChunkMsg2 = Message.Deserialize(bytes) as GetChunkMessage;

            Assert.IsNotNull(getChunkMsg2);
            Assert.AreEqual(getChunkMsg.MessageType, getChunkMsg2.MessageType);
            Assert.AreEqual(getChunkMsg.VersionM, getChunkMsg2.VersionM);
            Assert.AreEqual(getChunkMsg.VersionN, getChunkMsg2.VersionN);
            Assert.AreEqual(getChunkMsg.FileId, getChunkMsg2.FileId);
            Assert.AreEqual(getChunkMsg.ChunkNo, getChunkMsg2.ChunkNo);

            var chunkMsg = new ChunkMessage(9, 9, FileId1, 999999, body);

            bytes = chunkMsg.Serialize();
            var chunkMsg2 = Message.Deserialize(bytes) as ChunkMessage;

            Assert.IsNotNull(chunkMsg2);
            Assert.AreEqual(chunkMsg.MessageType, chunkMsg2.MessageType);
            Assert.AreEqual(chunkMsg.VersionM, chunkMsg2.VersionM);
            Assert.AreEqual(chunkMsg.VersionN, chunkMsg2.VersionN);
            Assert.AreEqual(chunkMsg.FileId, chunkMsg2.FileId);
            Assert.AreEqual(chunkMsg.ChunkNo, chunkMsg2.ChunkNo);
            CollectionAssert.AreEqual(chunkMsg.Body, chunkMsg2.Body);

            var putChunkMsg = new PutChunkMessage(9, 9, FileId1, 999999, 9, body);

            bytes = putChunkMsg.Serialize();
            var putChunkMsg2 = Message.Deserialize(bytes) as PutChunkMessage;

            Assert.IsNotNull(putChunkMsg2);
            Assert.AreEqual(putChunkMsg.MessageType, putChunkMsg2.MessageType);
            Assert.AreEqual(putChunkMsg.VersionM, putChunkMsg2.VersionM);
            Assert.AreEqual(putChunkMsg.VersionN, putChunkMsg2.VersionN);
            Assert.AreEqual(putChunkMsg.FileId, putChunkMsg2.FileId);
            Assert.AreEqual(putChunkMsg.ChunkNo, putChunkMsg2.ChunkNo);
            Assert.AreEqual(putChunkMsg.ReplicationDeg, putChunkMsg2.ReplicationDeg);
            CollectionAssert.AreEqual(putChunkMsg.Body, putChunkMsg2.Body);

            var storedMsg = new StoredMessage(9, 9, FileId1, 999999);

            bytes = storedMsg.Serialize();
            var storedMsg2 = Message.Deserialize(bytes) as StoredMessage;

            Assert.IsNotNull(storedMsg2);
            Assert.AreEqual(storedMsg.MessageType, storedMsg2.MessageType);
            Assert.AreEqual(storedMsg.VersionM, storedMsg2.VersionM);
            Assert.AreEqual(storedMsg.VersionN, storedMsg2.VersionN);
            Assert.AreEqual(storedMsg.FileId, storedMsg2.FileId);
            Assert.AreEqual(storedMsg.ChunkNo, storedMsg2.ChunkNo);

            var deleteMsg = new DeleteMessage(FileId1);

            bytes = deleteMsg.Serialize();
            var deleteMsg2 = Message.Deserialize(bytes) as DeleteMessage;

            Assert.IsNotNull(deleteMsg2);
            Assert.AreEqual(deleteMsg.MessageType, deleteMsg2.MessageType);

            var removedMsg = new RemovedMessage(9, 9, FileId1, 999999);

            bytes = removedMsg.Serialize();
            var removedMsg2 = Message.Deserialize(bytes) as RemovedMessage;

            Assert.IsNotNull(removedMsg2);
            Assert.AreEqual(removedMsg.MessageType, removedMsg2.MessageType);
            Assert.AreEqual(removedMsg.VersionM, removedMsg2.VersionM);
            Assert.AreEqual(removedMsg.VersionN, removedMsg2.VersionN);
            Assert.AreEqual(removedMsg.FileId, removedMsg2.FileId);
            Assert.AreEqual(removedMsg.ChunkNo, removedMsg2.ChunkNo);

            var lookupMsg = new LookupMessage(9, 9, FileId1);

            bytes = lookupMsg.Serialize();
            var lookupMsg2 = Message.Deserialize(bytes) as LookupMessage;

            Assert.IsNotNull(lookupMsg2);
            Assert.AreEqual(lookupMsg.MessageType, lookupMsg2.MessageType);
            Assert.AreEqual(lookupMsg.VersionM, lookupMsg2.VersionM);
            Assert.AreEqual(lookupMsg.VersionN, lookupMsg2.VersionN);
            Assert.AreEqual(lookupMsg.FileId, lookupMsg2.FileId);

            var gotMsg = new GotMessage(9, 9, FileId1);

            bytes = gotMsg.Serialize();
            var gotMsg2 = Message.Deserialize(bytes) as GotMessage;

            Assert.IsNotNull(gotMsg2);
            Assert.AreEqual(gotMsg.MessageType, gotMsg2.MessageType);
            Assert.AreEqual(gotMsg.VersionM, gotMsg2.VersionM);
            Assert.AreEqual(gotMsg.VersionN, gotMsg2.VersionN);
            Assert.AreEqual(gotMsg.FileId, gotMsg2.FileId);

            var ackMsg = new ACKMessage(9, 9, FileId1, 999999);

            bytes = ackMsg.Serialize();
            var ackMsg2 = Message.Deserialize(bytes) as ACKMessage;

            Assert.IsNotNull(ackMsg2);
            Assert.AreEqual(ackMsg.MessageType, ackMsg2.MessageType);
            Assert.AreEqual(ackMsg.VersionM, ackMsg2.VersionM);
            Assert.AreEqual(ackMsg.VersionN, ackMsg2.VersionN);
            Assert.AreEqual(ackMsg.FileId, ackMsg2.FileId);
            Assert.AreEqual(ackMsg.ChunkNo, ackMsg2.ChunkNo);
        }
コード例 #3
0
ファイル: DropdownSelector.cs プロジェクト: bsimser/xeva
 public void SetInitialSelection(LookupMessage message)
 {
     _itemsGrid.ActiveRow = _itemsGrid.Rows.Cast<UltraGridRow>().Where(r => (string)r.Cells["Name"].Value == message.Name).FirstOrDefault();
      Value = message.Name;
      RaiseItemSelected();
 }