Exemplo n.º 1
0
        public void CreateCommand_should_return_expected_result(ExplainVerbosity verbosity, string verbosityString)
        {
            var subject = new ExplainOperation(_databaseNamespace, _explainableOperation, _messageEncoderSettings)
            {
                Verbosity = verbosity
            };

            var expectedResult = new BsonDocument
            {
                { "explain", BsonDocument.Parse("{ find : 'test' }") },
                { "verbosity", verbosityString }
            };

            var endPoint     = new DnsEndPoint("localhost", 27017);
            var serverId     = new ServerId(new ClusterId(), endPoint);
            var connectionId = new ConnectionId(serverId);
            var helloResult  = new HelloResult(new BsonDocument {
                { "ok", 1 }, { "maxMessageSizeBytes", 48000000 }, { "maxWireVersion", WireVersion.Server36 }
            });
            var connectionDescription = new ConnectionDescription(connectionId, helloResult);
            var session = NoCoreSession.Instance;

            var result = subject.CreateExplainCommand(connectionDescription, session);

            result.Should().Be(expectedResult);
        }
        public async Task ExecuteAsync_should_not_throw_when_collection_does_not_exist()
        {
            var subject = new ExplainOperation(_databaseNamespace, _command, _messageEncoderSettings);

            var result = await ExecuteOperationAsync((IReadOperation <BsonDocument>) subject);

            result.Should().NotBeNull();
        }
Exemplo n.º 3
0
        public void Constructor_should_initialize_subject()
        {
            var subject = new ExplainOperation(_databaseNamespace, _command, _messageEncoderSettings);

            subject.DatabaseNamespace.Should().Be(_databaseNamespace);
            subject.Command.Should().Be(_command);
            subject.MessageEncoderSettings.Should().BeEquivalentTo(_messageEncoderSettings);
            subject.Verbosity.Should().Be(ExplainVerbosity.QueryPlanner);
        }
        public void Execute_should_not_throw_when_collection_does_not_exist(
            [Values(false, true)]
            bool async)
        {
            var subject = new ExplainOperation(_databaseNamespace, _command, _messageEncoderSettings);

            var result = ExecuteOperation((IReadOperation <BsonDocument>)subject, async);

            result.Should().NotBeNull();
        }
Exemplo n.º 5
0
        public void Execute_should_not_throw_when_collection_does_not_exist(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check().Supports(Feature.ExplainCommand);
            EnsureCollectionExists();
            var subject = new ExplainOperation(_databaseNamespace, _command, _messageEncoderSettings);

            var result = ExecuteOperation((IReadOperation <BsonDocument>)subject, async);

            result.Should().NotBeNull();
        }
Exemplo n.º 6
0
        public void CreateCommand_should_return_expected_result(ExplainVerbosity verbosity, string verbosityString)
        {
            var subject = new ExplainOperation(_databaseNamespace, _command, _messageEncoderSettings)
            {
                Verbosity = verbosity
            };

            var expectedResult = new BsonDocument
            {
                { "explain", _command },
                { "verbosity", verbosityString }
            };

            var result = subject.CreateCommand();

            result.Should().Be(expectedResult);
        }