Пример #1
0
 private void VerifyCommandSucceededEvent(CommandSucceededEvent actual, BsonDocument expected, string databaseName, string collectionName)
 {
     actual.CommandName.Should().Be(expected["command_name"].ToString());
     var expectedReply = (BsonDocument)expected["reply"];
     var reply = MassageReply(actual.CommandName, actual.Reply, expectedReply);
     reply.Should().BeEquivalentTo(expectedReply);
 }
        public void AfterSending(IEnumerable<RequestMessage> messages, ConnectionId connectionId)
        {
            foreach (var message in messages)
            {
                CommandState state;
                if (_state.TryGetValue(message.RequestId, out state) &&
                    state.ExpectedResponseType == ExpectedResponseType.None)
                {
                    state.Stopwatch.Stop();
                    if (_succeededEvent != null)
                    {
                        var @event = new CommandSucceededEvent(
                            state.CommandName,
                            state.NoResponseResponse ?? new BsonDocument("ok", 1),
                            state.OperationId,
                            message.RequestId,
                            connectionId,
                            state.Stopwatch.Elapsed);

                        _succeededEvent(@event);
                    }

                    _state.TryRemove(message.RequestId, out state);
                }
            }
        }