public void NotErrorMessage_ShouldNotHaveErrorPayload()
 {
     foreach (var message in messages.SkipLast(errorMessagesCount))
     {
         dynamic dynamicMessage = message;
         Assert.IsFalse(MessagingTestHelper.IsMessagePayloadError(dynamicMessage));
     }
 }
 public void AllMessages_ShouldBeCastedToDerviedType()
 {
     foreach (var message in messages)
     {
         dynamic dynamicMessage = message;
         Assert.IsTrue(MessagingTestHelper.IsMessagePayloadDerived(dynamicMessage));
     }
 }
 public void ErrorMessage_ShouldHaveErrorPayload()
 {
     foreach (var message in messages.TakeLast(errorMessagesCount))
     {
         dynamic dynamicMessage = message;
         Assert.IsTrue(MessagingTestHelper.IsMessagePayloadError(dynamicMessage));
     }
 }
Exemple #4
0
        public void DeserializeMessage_ShouldReturnDerivedTypeMessage()
        {
            foreach (var message in messages)
            {
                var     serialized   = MessageSerializer.SerializeMessage(message);
                dynamic deserialized = MessageSerializer.DeserializeMessage(serialized);

                Assert.IsTrue(MessagingTestHelper.IsMessagePayloadDerived(deserialized));
            }
        }
Exemple #5
0
        public void DeserializeMessage_ShouldThrowIfSetToThrowWithoutAgentId()
        {
            foreach (var message in messages)
            {
                var serialized = MessagingTestHelper.SerializeWithoutProperties(message, "agentID");

                Assert.Throws <JsonSerializationException>(() => MessageSerializer.DeserializeMessage(serialized, true));
            }

            Assert.Pass();
        }
Exemple #6
0
        public void MessageSerializer_ShouldSetAgentIdToZeroIfNotProvided()
        {
            foreach (var message in messages)
            {
                var serialized   = MessagingTestHelper.SerializeWithoutProperties(message, "agentID");
                var deserialized = MessageSerializer.DeserializeMessage(serialized);

                Assert.AreEqual(0, deserialized.AgentId);
            }

            Assert.Pass();
        }
Exemple #7
0
        public void DeserializeMessage_ShouldReturnDerivedTypeMessageAfterAddingToList()
        {
            var deserializedMessages = new List <BaseMessage>();

            foreach (var message in messages)
            {
                var serialized = MessageSerializer.SerializeMessage(message);
                deserializedMessages.Add(MessageSerializer.DeserializeMessage(serialized));
            }

            foreach (var deserializedMessage in deserializedMessages)
            {
                dynamic dynamicMessage = deserializedMessage;
                Assert.IsTrue(MessagingTestHelper.IsMessagePayloadDerived(dynamicMessage));
            }
        }
 public void SetUp()
 {
     messages = MessagingTestHelper.CreateMessagesOfAllTypes();
 }