Пример #1
0
 public void WriteMessage_should_throw_if_message_is_null()
 {
     using (var stream = new MemoryStream())
     {
         var    subject = new GetMoreMessageBinaryEncoder(stream, __messageEncoderSettings);
         Action action  = () => subject.WriteMessage(null);
         action.ShouldThrow <ArgumentNullException>();
     }
 }
Пример #2
0
 public void WriteMessage_should_write_a_message()
 {
     using (var stream = new MemoryStream())
     {
         var subject = new GetMoreMessageBinaryEncoder(stream, __messageEncoderSettings);
         subject.WriteMessage(__testMessage);
         var bytes = stream.ToArray();
         bytes.Should().Equal(__testMessageBytes);
     }
 }
Пример #3
0
 public void WriteMessage_should_throw_if_binaryWriter_was_not_provided()
 {
     using (var stream = new MemoryStream())
         using (var binaryReader = new BsonBinaryReader(stream))
         {
             var    subject = new GetMoreMessageBinaryEncoder(binaryReader, null);
             Action action  = () => subject.WriteMessage(__testMessage);
             action.ShouldThrow <InvalidOperationException>();
         }
 }
 public void ReadMessage_should_read_a_message()
 {
     using (var stream = new MemoryStream(__testMessageBytes))
     {
         var subject = new GetMoreMessageBinaryEncoder(stream, __messageEncoderSettings);
         var message = subject.ReadMessage();
         message.BatchSize.Should().Be(__batchSize);
         message.CollectionNamespace.Should().Be(__collectionNamespace);
         message.CursorId.Should().Be(__cursorId);
         message.RequestId.Should().Be(__requestId);
     }
 }
Пример #5
0
 public void ReadMessage_should_read_a_message()
 {
     using (var stream = new MemoryStream(__testMessageBytes))
     {
         var subject = new GetMoreMessageBinaryEncoder(stream, __messageEncoderSettings);
         var message = subject.ReadMessage();
         message.BatchSize.Should().Be(__batchSize);
         message.CollectionNamespace.Should().Be(__collectionNamespace);
         message.CursorId.Should().Be(__cursorId);
         message.RequestId.Should().Be(__requestId);
     }
 }
        public void ReadMessage_should_throw_when_opcode_is_invalid()
        {
            var bytes = (byte[])__testMessageBytes.Clone();

            bytes[12]++;

            using (var stream = new MemoryStream(bytes))
            {
                var subject   = new GetMoreMessageBinaryEncoder(stream, __messageEncoderSettings);
                var exception = Record.Exception(() => subject.ReadMessage());
                exception.Should().BeOfType <FormatException>();
                exception.Message.Should().Be("GetMore message opcode is not OP_GET_MORE.");
            }
        }
Пример #7
0
 public void ReadMessage_should_read_a_message()
 {
     using (var stream = new MemoryStream(__testMessageBytes))
         using (var binaryReader = new BsonBinaryReader(stream))
         {
             var subject = new GetMoreMessageBinaryEncoder(binaryReader, null);
             var message = subject.ReadMessage();
             message.BatchSize.Should().Be(__batchSize);
             message.CollectionName.Should().Be(__collectionName);
             message.CursorId.Should().Be(__cursorId);
             message.DatabaseName.Should().Be(__databaseName);
             message.RequestId.Should().Be(__requestId);
         }
 }
 public void WriteMessage_should_throw_if_message_is_null()
 {
     using (var stream = new MemoryStream())
     {
         var subject = new GetMoreMessageBinaryEncoder(stream, __messageEncoderSettings);
         Action action = () => subject.WriteMessage(null);
         action.ShouldThrow<ArgumentNullException>();
     }
 }
 public void WriteMessage_should_write_a_message()
 {
     using (var stream = new MemoryStream())
     {
         var subject = new GetMoreMessageBinaryEncoder(stream, __messageEncoderSettings);
         subject.WriteMessage(__testMessage);
         var bytes = stream.ToArray();
         bytes.Should().Equal(__testMessageBytes);
     }
 }
 public void WriteMessage_should_throw_if_binaryWriter_was_not_provided()
 {
     using (var stream = new MemoryStream())
     using (var binaryReader = new BsonBinaryReader(stream))
     {
         var subject = new GetMoreMessageBinaryEncoder(binaryReader, null);
         Action action = () => subject.WriteMessage(__testMessage);
         action.ShouldThrow<InvalidOperationException>();
     }
 }
 public void ReadMessage_should_read_a_message()
 {
     using (var stream = new MemoryStream(__testMessageBytes))
     using (var binaryReader = new BsonBinaryReader(stream))
     {
         var subject = new GetMoreMessageBinaryEncoder(binaryReader, null);
         var message = subject.ReadMessage();
         message.BatchSize.Should().Be(__batchSize);
         message.CollectionName.Should().Be(__collectionName);
         message.CursorId.Should().Be(__cursorId);
         message.DatabaseName.Should().Be(__databaseName);
         message.RequestId.Should().Be(__requestId);
     }
 }