Exemplo n.º 1
0
        public void TestGenericDeserialize()
        {
            NotificationResponse nr = new NotificationResponse();
            nr.DestType = BaseResponse.DEST_TYPE.FACTION;
            nr.Destination = new List<long>() { 2194 };
            nr.NotificationText = "Test String";
            nr.Time = 2000;
            nr.Font = Sandbox.Common.MyFontEnum.Red;

            byte[] buffer = nr.serialize();

            BaseResponse msg = BaseResponse.messageFromBytes(buffer);

            Assert.IsInstanceOfType(msg, typeof(NotificationResponse));
            Assert.AreEqual(nr.MsgType, msg.MsgType);
            Assert.AreEqual(nr.DestType, msg.DestType);
            CollectionAssert.AreEqual(nr.Destination, msg.Destination);
            Assert.AreEqual(nr.NotificationText, (msg as NotificationResponse).NotificationText);
            Assert.AreEqual(nr.Time, (msg as NotificationResponse).Time);
            Assert.AreEqual(nr.Font, (msg as NotificationResponse).Font);
        }
Exemplo n.º 2
0
        public void TestNotificationResponse()
        {
            NotificationResponse nr = new NotificationResponse();
            nr.DestType = BaseResponse.DEST_TYPE.FACTION;
            nr.Destination = new List<long>() { 1, 2 };
            nr.NotificationText = "Test String";
            nr.Time = 2000;
            nr.Font = Sandbox.Common.MyFontEnum.Red;

            byte[] buffer = nr.serialize();

            NotificationResponse nr2 = new NotificationResponse();
            nr2.deserialize(new VRage.ByteStream(buffer, buffer.Length));

            Assert.AreEqual(nr.MsgType, nr2.MsgType);
            Assert.AreEqual(nr.DestType, nr2.DestType);
            CollectionAssert.AreEqual(nr.Destination, nr2.Destination);
            Assert.AreEqual(nr.NotificationText, nr2.NotificationText);
            Assert.AreEqual(nr.Time, nr2.Time);
            Assert.AreEqual(nr.Font, nr2.Font);
        }