public void constructor_should_initialize_subject() { var subject = new ListCollectionsUsingQueryOperation(_databaseNamespace, _messageEncoderSettings); subject.DatabaseNamespace.Should().BeSameAs(_databaseNamespace); subject.MessageEncoderSettings.Should().BeSameAs(_messageEncoderSettings); subject.Filter.Should().BeNull(); }
public void Filter_get_and_set_should_work() { var subject = new ListCollectionsUsingQueryOperation(_databaseNamespace, _messageEncoderSettings); var filter = new BsonDocument("name", "abc"); subject.Filter = filter; var result = subject.Filter; result.Should().BeSameAs(filter); }
public void Execute_should_return_the_expected_result( [Values(false, true)] bool async) { 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); }
public void Execute_should_return_the_expected_result( [Values(false, true)] bool async) { RequireServer.Where(clusterTypes: ClusterTypes.StandaloneOrReplicaSet, storageEngines: "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); }
public void Execute_should_return_the_expected_result_when_filter_is_used(string filterString, string expectedName, bool async) { 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_throw_when_filter_name_is_not_a_string_and_connected_to_older_server( [Values(false, true)] bool async) { var filter = new BsonDocument("name", new BsonRegularExpression("^abc")); var subject = new ListCollectionsUsingQueryOperation(_databaseNamespace, _messageEncoderSettings) { Filter = filter }; Action action = () => ExecuteOperation(subject, async); action.ShouldThrow<NotSupportedException>(); }
public void Execute_should_return_the_expected_result_when_the_database_does_not_exist( [Values(false, true)] bool async) { var databaseNamespace = new DatabaseNamespace(_databaseNamespace.DatabaseName + "-not"); var subject = new ListCollectionsUsingQueryOperation(databaseNamespace, _messageEncoderSettings); var result = ExecuteOperation(subject, async); var list = ReadCursorToEnd(result, async); list.Should().HaveCount(0); }
public void Execute_should_return_the_expected_result_when_filter_is_used(string filterString, string expectedName, bool async) { RequireServer.Where(clusterTypes: ClusterTypes.StandaloneOrReplicaSet, storageEngines: "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_the_database_does_not_exist( [Values(false, true)] bool async) { RequireServer.Where(clusterTypes: ClusterTypes.StandaloneOrReplicaSet, storageEngines: "mmapv1"); var databaseNamespace = new DatabaseNamespace(_databaseNamespace.DatabaseName + "-not"); var subject = new ListCollectionsUsingQueryOperation(databaseNamespace, _messageEncoderSettings); var result = ExecuteOperation(subject, async); var list = ReadCursorToEnd(result, async); list.Should().HaveCount(0); }