public void Constructor_should_initialize_instance() { var subject = new GetMoreMessage(_requestId, _collectionNamespace, _cursorId, _batchSize); subject.BatchSize.Should().Be(_batchSize); subject.CursorId.Should().Be(_cursorId); subject.CollectionNamespace.Should().Be(_collectionNamespace); subject.RequestId.Should().Be(_requestId); }
public void GetEncoder_should_return_encoder() { var mockEncoder = Substitute.For<IMessageEncoder<GetMoreMessage>>(); var mockEncoderFactory = Substitute.For<IMessageEncoderFactory>(); mockEncoderFactory.GetGetMoreMessageEncoder().Returns(mockEncoder); var subject = new GetMoreMessage(_requestId, _collectionNamespace, _cursorId, _batchSize); var encoder = subject.GetEncoder(mockEncoderFactory); encoder.Should().BeSameAs(mockEncoder); }
public void GetEncoder_should_return_encoder() { var subject = new GetMoreMessage(_requestId, _collectionNamespace, _cursorId, _batchSize); var stubEncoderFactory = Substitute.For<IMessageEncoderFactory>(); var stubEncoder = Substitute.For<IMessageEncoder>(); stubEncoderFactory.GetGetMoreMessageEncoder().Returns(stubEncoder); var result = subject.GetEncoder(stubEncoderFactory); result.Should().BeSameAs(stubEncoder); }
public void GetEncoder_should_return_encoder() { var subject = new GetMoreMessage(_requestId, _collectionNamespace, _cursorId, _batchSize); var mockEncoderFactory = new Mock<IMessageEncoderFactory>(); var encoder = new Mock<IMessageEncoder>().Object; mockEncoderFactory.Setup(f => f.GetGetMoreMessageEncoder()).Returns(encoder); var result = subject.GetEncoder(mockEncoderFactory.Object); result.Should().BeSameAs(encoder); }
// static constructor static GetMoreMessageJsonEncoderTests() { __testMessage = new GetMoreMessage(__requestId, __databaseName, __collectionName, __cursorId, __batchSize); __testMessageJson = "{ " + "\"opcode\" : \"getMore\", " + "\"requestId\" : 1, " + "\"database\" : \"d\", " + "\"collection\" : \"c\", " + "\"cursorId\" : NumberLong(2), " + "\"batchSize\" : 3" + " }"; }
// static constructor static GetMoreMessageBinaryEncoderTests() { __testMessage = new GetMoreMessage(__requestId, __collectionNamespace, __cursorId, __batchSize); __testMessageBytes = new byte[] { 0, 0, 0, 0, // messageLength 1, 0, 0, 0, // requestId 0, 0, 0, 0, // responseTo 213, 7, 0, 0, // opcode = 2004 0, 0, 0, 0, // reserved (byte)'d', (byte)'.', (byte)'c', 0, // fullCollectionName 3, 0, 0, 0, // batchSize 2, 0, 0, 0, 0, 0, 0, 0 // cursorId }; __testMessageBytes[0] = (byte)__testMessageBytes.Length; }
private void ProcessGetMoreMessage(GetMoreMessage originalMessage, ConnectionId connectionId, Stopwatch stopwatch) { var commandName = "getMore"; var operationId = EventContext.OperationId; if (_startedEvent != null) { var command = new BsonDocument { { commandName, originalMessage.CursorId }, { "collection", originalMessage.CollectionNamespace.CollectionName }, { "batchSize", originalMessage.BatchSize, originalMessage.BatchSize > 0 } }; var @event = new CommandStartedEvent( "getMore", command, originalMessage.CollectionNamespace.DatabaseNamespace, operationId, originalMessage.RequestId, connectionId); _startedEvent(@event); } if (_shouldTrackState) { _state.TryAdd(originalMessage.RequestId, new CommandState { CommandName = commandName, OperationId = operationId, Stopwatch = stopwatch, QueryNamespace = originalMessage.CollectionNamespace, ExpectedResponseType = ExpectedResponseType.Query }); } }