예제 #1
0
        public void constructor_should_initialize_subject()
        {
            var subject = new ListIndexesUsingQueryOperation(_collectionNamespace, _messageEncoderSettings);

            subject.CollectionNamespace.Should().BeSameAs(_collectionNamespace);
            subject.MessageEncoderSettings.Should().BeSameAs(_messageEncoderSettings);
        }
예제 #2
0
        public void CollectionNamespace_get_should_return_expected_result()
        {
            var subject = new ListIndexesUsingQueryOperation(_collectionNamespace, _messageEncoderSettings);

            var result = subject.CollectionNamespace;

            result.Should().BeSameAs(_collectionNamespace);
        }
예제 #3
0
        public void Execute_should_throw_when_binding_is_null(
            [Values(false, true)]
            bool async)
        {
            var subject = new ListIndexesUsingQueryOperation(_collectionNamespace, _messageEncoderSettings);

            Action action = () => ExecuteOperation(subject, null, async);

            action.ShouldThrow <ArgumentNullException>().And.ParamName.Should().Be("binding");
        }
예제 #4
0
        public void BatchSize_get_and_set_should_work()
        {
            var subject   = new ListIndexesUsingQueryOperation(_collectionNamespace, _messageEncoderSettings);
            int batchSize = 2;

            subject.BatchSize = batchSize;
            var result = subject.BatchSize;

            result.Should().Be(batchSize);
        }
예제 #5
0
        public void Execute_should_return_expected_result_when_database_does_not_exist(
            [Values(false, true)]
            bool async)
        {
            DropDatabase(async);
            var subject = new ListIndexesUsingQueryOperation(_collectionNamespace, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);
            var list   = ReadCursorToEnd(result, async);

            list.Count.Should().Be(0);
        }
예제 #6
0
        public void Execute_should_return_expected_result(
            [Values(false, true)]
            bool async)
        {
            EnsureCollectionExists(async);
            var subject = new ListIndexesUsingQueryOperation(_collectionNamespace, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);
            var list   = ReadCursorToEnd(result, async);

            list.Select(index => index["name"].AsString).Should().BeEquivalentTo("_id_");
        }
예제 #7
0
        public void Execute_should_return_expected_result_when_database_does_not_exist(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet).StorageEngine("mmapv1");
            DropDatabase(async);
            var subject = new ListIndexesUsingQueryOperation(_collectionNamespace, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);
            var list   = ReadCursorToEnd(result, async);

            list.Count.Should().Be(0);
        }
예제 #8
0
        public void Execute_should_return_expected_result(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet).StorageEngine("mmapv1");
            EnsureCollectionExists(async);
            var subject = new ListIndexesUsingQueryOperation(_collectionNamespace, _messageEncoderSettings);

            var result = ExecuteOperation(subject, async);
            var list   = ReadCursorToEnd(result, async);

            list.Select(index => index["name"].AsString).Should().BeEquivalentTo("_id_");
        }
예제 #9
0
        public void Execute_should_return_the_expected_result_when_batchSize_is_used([Values(false, true)] bool async)
        {
            RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet).StorageEngine("mmapv1").Authentication(authentication: false);
            EnsureCollectionExists(async);
            int batchSize = 3;
            var subject   = new ListIndexesUsingQueryOperation(_collectionNamespace, _messageEncoderSettings)
            {
                BatchSize = batchSize
            };

            using (var result = ExecuteOperation(subject, async) as AsyncCursor <BsonDocument>)
            {
                result._batchSize().Should().Be(batchSize);
            }
        }