public void ReadMessage_should_read_a_message()
 {
     using (var stream = new MemoryStream(__testMessageBytes))
     {
         var subject = new KillCursorsMessageBinaryEncoder(stream, __messageEncoderSettings);
         var message = subject.ReadMessage();
         message.CursorIds.Should().Equal(__cursorIds);
         message.RequestId.Should().Be(__testMessage.RequestId);
     }
 }
Exemple #2
0
 public void ReadMessage_should_throw_if_binaryReader_was_not_provided()
 {
     using (var stream = new MemoryStream())
         using (var binaryWriter = new BsonBinaryWriter(stream))
         {
             var    subject = new KillCursorsMessageBinaryEncoder(null, binaryWriter);
             Action action  = () => subject.ReadMessage();
             action.ShouldThrow <InvalidOperationException>();
         }
 }
 public void ReadMessage_should_read_a_message()
 {
     using (var stream = new MemoryStream(__testMessageBytes))
     {
         var subject = new KillCursorsMessageBinaryEncoder(stream, __messageEncoderSettings);
         var message = subject.ReadMessage();
         message.CursorIds.Should().Equal(__cursorIds);
         message.RequestId.Should().Be(__testMessage.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 KillCursorsMessageBinaryEncoder(stream, __messageEncoderSettings);
                var exception = Record.Exception(() => subject.ReadMessage());
                exception.Should().BeOfType <FormatException>();
                exception.Message.Should().Be("KillCursors message opcode is not OP_KILL_CURSORS.");
            }
        }
 public void ReadMessage_should_throw_if_binaryReader_was_not_provided()
 {
     using (var stream = new MemoryStream())
     using (var binaryWriter = new BsonBinaryWriter(stream))
     {
         var subject = new KillCursorsMessageBinaryEncoder(null, binaryWriter);
         Action action = () => subject.ReadMessage();
         action.ShouldThrow<InvalidOperationException>();
     }
 }