public void WriteMessage_should_throw_if_message_is_null() { using (var textWriter = new StringWriter()) { var subject = new InsertMessageJsonEncoder <BsonDocument>(null, textWriter, __messageEncoderSettings, __serializer); Action action = () => subject.WriteMessage(null); action.ShouldThrow <ArgumentNullException>(); } }
public void WriteMessage_should_throw_if_textWriter_was_not_provided() { using (var textReader = new StringReader("")) { var subject = new InsertMessageJsonEncoder <BsonDocument>(textReader, null, __messageEncoderSettings, __serializer); Action action = () => subject.WriteMessage(__testMessage); action.ShouldThrow <InvalidOperationException>(); } }
public void WriteMessage_should_write_a_message() { using (var textWriter = new StringWriter()) { var subject = new InsertMessageJsonEncoder <BsonDocument>(null, textWriter, __messageEncoderSettings, __serializer); subject.WriteMessage(__testMessage); var json = textWriter.ToString(); json.Should().Be(__testMessageJson); } }
public void ReadMessage_should_throw_if_jsonReader_was_not_provided() { using (var stringWriter = new StringWriter()) using (var jsonWriter = new JsonWriter(stringWriter)) { var subject = new InsertMessageJsonEncoder <BsonDocument>(null, jsonWriter, __serializer); Action action = () => subject.ReadMessage(); action.ShouldThrow <InvalidOperationException>(); } }
public void ReadMessage_should_read_a_message() { using (var textReader = new StringReader(__testMessageJson)) { var subject = new InsertMessageJsonEncoder <BsonDocument>(textReader, null, __messageEncoderSettings, __serializer); var message = subject.ReadMessage(); message.CollectionNamespace.Should().Be(__collectionNamespace); message.ContinueOnError.Should().Be(__continueOnError); message.DocumentSource.Batch.Should().Equal(__documentSource.Batch); message.MaxBatchCount.Should().Be(__maxBatchCount); message.MaxMessageSize.Should().Be(__maxMessageSize); message.RequestId.Should().Be(__requestId); message.Serializer.Should().BeSameAs(__serializer); } }