Example #1
0
        public void Execute_should_throw_when_filter_name_is_not_a_string_and_connected_to_older_server(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check().VersionLessThan("2.7.0").ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet);
            var filter  = new BsonDocument("name", new BsonRegularExpression("^abc"));
            var subject = new ListCollectionsUsingQueryOperation(_databaseNamespace, _messageEncoderSettings)
            {
                Filter = filter
            };

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

            action.ShouldThrow <NotSupportedException>();
        }
Example #2
0
        public void Execute_should_return_the_expected_result(
            [Values(false, true)]
            bool async)
        {
            RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet).StorageEngine("mmapv1");
            EnsureCollectionsExist();
            var subject       = new ListCollectionsUsingQueryOperation(_databaseNamespace, _messageEncoderSettings);
            var expectedNames = new[] { "regular", "capped" };

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

            list.Count.Should().BeGreaterThan(0);
            list.Select(c => c["name"].AsString).Where(n => n != "system.indexes").Should().BeEquivalentTo(expectedNames);
        }
Example #3
0
        public void Execute_should_return_the_expected_result_when_filter_is_used(string filterString, string expectedName, bool async)
        {
            RequireServer.Check().ClusterTypes(ClusterType.Standalone, ClusterType.ReplicaSet).StorageEngine("mmapv1");
            EnsureCollectionsExist();
            var filter  = BsonDocument.Parse(filterString);
            var subject = new ListCollectionsUsingQueryOperation(_databaseNamespace, _messageEncoderSettings)
            {
                Filter = filter
            };

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

            list.Should().HaveCount(1);
            list[0]["name"].AsString.Should().Be(expectedName);
        }
        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);
            EnsureCollectionsExist();
            int batchSize = 1;
            var subject   = new ListCollectionsUsingQueryOperation(_databaseNamespace, _messageEncoderSettings)
            {
                BatchSize = batchSize
            };

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