コード例 #1
0
        public void JsonMessageDeserializer_WhenGivenNullTextWriter_ThrowsArgumentNullException() {
            // given
            IMessageTypeResolver resolver = new UnitTestMessageTypeResolver();
            TextReader textReader = null;

            // when
            ArgumentNullException exception =
                Assert.Throws<ArgumentNullException>(
                    () => new JsonMessageDeserializer(resolver, textReader));

            // then
            Assert.That(() => exception.ParamName, Is.EqualTo("textReader"));
        }
コード例 #2
0
        public void JsonMessageSerializer_WhenGivenNullMessage_ThrowsArgumentNullException() {
            // given
            IMessageTypeResolver resolver = new UnitTestMessageTypeResolver();
            TextWriter textWriter = new StringWriter();

            // when
            ArgumentNullException exception =
                Assert.Throws<ArgumentNullException>(
                    () => new JsonMessageSerializer(resolver, textWriter).SerializeMessage(null));

            // then
            Assert.That(() => exception.ParamName, Is.EqualTo("message"));
        }
コード例 #3
0
        public void JsonMessageSerializer_WhenUnderlyingMediumFails_ThrowsMessageException() {
            // given
            IMessageTypeResolver resolver = new UnitTestMessageTypeResolver();
            TextWriter textWriter = new StringWriter();
            textWriter.Dispose(); // so stringwriter will throw ObjectDisposedException

            // when / then
            MessageTransferException exception =
                Assert.Throws<MessageTransferException>(
                    () => new JsonMessageSerializer(resolver, textWriter).SerializeMessage(new FakeMessage()));

            // then
            Assert.That(() => exception.InnerException, Is.InstanceOf<ObjectDisposedException>());
        }