Esempio n. 1
0
 public void WriteMessage_should_throw_if_message_is_null()
 {
     using (var textWriter = new StringWriter())
     {
         var    subject = new ReplyMessageJsonEncoder <BsonDocument>(null, textWriter, __messageEncoderSettings, __serializer);
         Action action  = () => subject.WriteMessage(null);
         action.ShouldThrow <ArgumentNullException>();
     }
 }
Esempio n. 2
0
 public void WriteMessage_should_throw_if_textWriter_was_not_provided()
 {
     using (var textReader = new StringReader(""))
     {
         var    subject = new ReplyMessageJsonEncoder <BsonDocument>(textReader, null, __messageEncoderSettings, __serializer);
         Action action  = () => subject.WriteMessage(__testMessage);
         action.ShouldThrow <InvalidOperationException>();
     }
 }
Esempio n. 3
0
 public void WriteMessage_should_write_a_query_failure_message()
 {
     using (var textWriter = new StringWriter())
     {
         var subject = new ReplyMessageJsonEncoder <BsonDocument>(null, textWriter, __messageEncoderSettings, __serializer);
         subject.WriteMessage(__queryFailureMessage);
         var json = textWriter.ToString();
         json.Should().Be(__queryFailureMessageJson);
     }
 }
Esempio n. 4
0
 public void ReadMessage_should_throw_if_jsonReader_was_not_provided()
 {
     using (var stringWriter = new StringWriter())
         using (var jsonWriter = new JsonWriter(stringWriter))
         {
             var    subject = new ReplyMessageJsonEncoder <BsonDocument>(null, jsonWriter, __serializer);
             Action action  = () => subject.ReadMessage();
             action.ShouldThrow <InvalidOperationException>();
         }
 }
Esempio n. 5
0
 public void WriteMessage_should_write_a_message()
 {
     using (var stringWriter = new StringWriter())
         using (var jsonWriter = new JsonWriter(stringWriter))
         {
             var subject = new ReplyMessageJsonEncoder <BsonDocument>(null, jsonWriter, __serializer);
             subject.WriteMessage(__testMessage);
             var json = stringWriter.ToString();
             json.Should().Be(__testMessageJson);
         }
 }
Esempio n. 6
0
 public void ReadMessage_should_read_a_query_failure_message()
 {
     using (var textReader = new StringReader(__queryFailureMessageJson))
     {
         var subject = new ReplyMessageJsonEncoder <BsonDocument>(textReader, null, __messageEncoderSettings, __serializer);
         var message = subject.ReadMessage();
         message.AwaitCapable.Should().Be(false);
         message.CursorId.Should().Be(__cursorId);
         message.CursorNotFound.Should().Be(true);
         message.Documents.Should().BeNull();
         message.NumberReturned.Should().Be(0);
         message.QueryFailure.Should().Be(true);
         message.QueryFailureDocument.Should().Be(__queryFailureDocument);
         message.Serializer.Should().BeSameAs(__serializer);
         message.StartingFrom.Should().Be(0);
         message.RequestId.Should().Be(__requestId);
         message.ResponseTo.Should().Be(__responseTo);
     }
 }
Esempio n. 7
0
 public void ReadMessage_should_read_a_message()
 {
     using (var stringReader = new StringReader(__testMessageJson))
         using (var jsonReader = new JsonReader(stringReader))
         {
             var subject = new ReplyMessageJsonEncoder <BsonDocument>(jsonReader, null, __serializer);
             var message = subject.ReadMessage();
             message.AwaitCapable.Should().Be(__awaitCapable);
             message.CursorId.Should().Be(__cursorId);
             message.CursorNotFound.Should().Be(__cursorNotFound);
             message.Documents.Should().Equal(__documents);
             message.NumberReturned.Should().Be(__numberReturned);
             message.QueryFailure.Should().Be(false);
             message.QueryFailureDocument.Should().Be(null);
             message.Serializer.Should().BeSameAs(__serializer);
             message.StartingFrom.Should().Be(__startingFrom);
             message.RequestId.Should().Be(__requestId);
             message.ResponseTo.Should().Be(__responseTo);
         }
 }