public void deserializer_defined_but_not_for_test_message_Deserialize_throws_MissingMessageDeserializerException() { var messageSerialization = new MessageSerialization(); messageSerialization.RegisterDeserializer(TestMessage.TypeId, new TestMessageDeserializer()); Assert.Throws<MissingMessageDeserializerException>(() => messageSerialization.Deserialize(0, new byte[1])); }
public void deserializer_defined_but_not_for_test_message_Deserialize_throws_MissingMessageDeserializerException() { var messageSerialization = new MessageSerialization(); messageSerialization.RegisterDeserializer(TestMessage.TypeId, new TestMessageDeserializer()); Assert.Throws <MissingMessageDeserializerException>(() => messageSerialization.Deserialize(0, new byte[1])); }
public void deserializer_defined_for_message_with_MessageTypeId_65535_Deserialize_creates_object() { var messageSerialization = new MessageSerialization(); messageSerialization.RegisterDeserializer(CustomMessage.TypeId, new TestMessageDeserializer()); Assert.IsNotNull(messageSerialization.Deserialize(CustomMessage.TypeId, new byte[1])); }
public void deserializer_defined_for_test_message_Deserialize_creates_object() { var messageSerialization = new MessageSerialization(); messageSerialization.RegisterDeserializer(TestMessage.TypeId, new TestMessageDeserializer()); Assert.IsInstanceOf <TestMessage>(messageSerialization.Deserialize(1, new byte[1])); }
public void DeserializationTest() { var serialized = SampleMessage.Serialize(); var deserialized = MessageSerialization.Deserialize(serialized); Assert.AreEqual(deserialized, SampleMessage); Assert.IsInstanceOf(typeof(JObject), deserialized.payload["another key"]); }
public void default_deserializer_defined_but_no_specific_message_deserializer_for_test_message_use_default_deserializer() { var messageSerialization = new MessageSerialization { DefaultDeserializer = new TestMessageDeserializer() }; Assert.IsInstanceOf <TestMessage>(messageSerialization.Deserialize(0, new byte[1])); }
public void MessageDeserializationException_should_be_thrown_on_exception_while_deserializing_message() { var messageSerialization = new MessageSerialization(); messageSerialization.RegisterSerializer(ExceptionTestMessage.TypeId, new ExceptionTestMessageSerializer()); messageSerialization.RegisterDeserializer(ExceptionTestMessage.TypeId, new ExceptionTestMessageDeserializer()); var messageThatCausesExceptionOnDeserialization = new ExceptionTestMessage(false, true); var message = messageSerialization.Serialize(messageThatCausesExceptionOnDeserialization); var exception = Assert.Throws <MessageDeserializationException>(() => messageSerialization.Deserialize(ExceptionTestMessage.TypeId, message)); Assert.IsInstanceOf <TestException>(exception.InnerException); }
public void deserializer_defined_for_test_message_Deserialize_creates_object() { var messageSerialization = new MessageSerialization(); messageSerialization.RegisterDeserializer(TestMessage.TypeId, new TestMessageDeserializer()); Assert.IsInstanceOf<TestMessage>(messageSerialization.Deserialize(1, new byte[1])); }
public void default_deserializer_defined_but_no_specific_message_deserializer_for_test_message_use_default_deserializer() { var messageSerialization = new MessageSerialization { DefaultDeserializer = new TestMessageDeserializer() }; Assert.IsInstanceOf<TestMessage>(messageSerialization.Deserialize(0, new byte[1])); }
public void no_deserializer_defined_Deserialize_throws_MissingMessageDeserializerException() { var messageSerialization = new MessageSerialization(); Assert.Throws<MissingMessageDeserializerException>(() => messageSerialization.Deserialize(TestMessage.TypeId, new byte[1])); }
public void MessageDeserializationException_should_be_thrown_on_exception_while_deserializing_message() { var messageSerialization = new MessageSerialization(); messageSerialization.RegisterSerializer(ExceptionTestMessage.TypeId, new ExceptionTestMessageSerializer()); messageSerialization.RegisterDeserializer(ExceptionTestMessage.TypeId, new ExceptionTestMessageDeserializer()); var messageThatCausesExceptionOnDeserialization = new ExceptionTestMessage(false, true); var message = messageSerialization.Serialize(messageThatCausesExceptionOnDeserialization); var exception = Assert.Throws<MessageDeserializationException>(() => messageSerialization.Deserialize(ExceptionTestMessage.TypeId, message)); Assert.IsInstanceOf<TestException>(exception.InnerException); }
public void deserializer_defined_for_message_with_MessageTypeId_65535_Deserialize_creates_object() { var messageSerialization = new MessageSerialization(); messageSerialization.RegisterDeserializer(CustomMessage.TypeId, new TestMessageDeserializer()); Assert.IsNotNull(messageSerialization.Deserialize(CustomMessage.TypeId, new byte[1])); }
public void no_deserializer_defined_Deserialize_throws_MissingMessageDeserializerException() { var messageSerialization = new MessageSerialization(); Assert.Throws <MissingMessageDeserializerException>(() => messageSerialization.Deserialize(TestMessage.TypeId, new byte[1])); }