public void constructor_should_initialize_subject() { var subject = new ListCollectionsUsingCommandOperation(_databaseNamespace, _messageEncoderSettings); subject.DatabaseNamespace.Should().BeSameAs(_databaseNamespace); subject.MessageEncoderSettings.Should().BeSameAs(_messageEncoderSettings); subject.Filter.Should().BeNull(); }
public void NameOnly_get_and_set_should_work( [Values(null, false, true)] bool?nameOnly) { var subject = new ListCollectionsUsingCommandOperation(_databaseNamespace, _messageEncoderSettings); subject.NameOnly = nameOnly; var result = subject.NameOnly; result.Should().Be(nameOnly); }
public void Filter_get_and_set_should_work() { var subject = new ListCollectionsUsingCommandOperation(_databaseNamespace, _messageEncoderSettings); var filter = new BsonDocument("name", "abc"); subject.Filter = filter; var result = subject.Filter; result.Should().BeSameAs(filter); }
public void BatchSize_get_and_set_should_work() { var subject = new ListCollectionsUsingCommandOperation(_databaseNamespace, _messageEncoderSettings); int batchSize = 2; subject.BatchSize = batchSize; var result = subject.BatchSize; result.Should().Be(batchSize); }
public void Execute_should_send_session_id_when_supported( [Values(false, true)] bool async) { RequireServer.Check(); EnsureCollectionsExist(); var subject = new ListCollectionsUsingCommandOperation(_databaseNamespace, _messageEncoderSettings); var expectedNames = new[] { "regular", "capped" }; VerifySessionIdWasSentWhenSupported(subject, "listCollections", async); }
public void RetryRequested_get_and_set_should_work( [Values(false, true)] bool value) { var subject = new ListCollectionsUsingCommandOperation(_databaseNamespace, _messageEncoderSettings); subject.RetryRequested = value; var result = subject.RetryRequested; result.Should().Be(value); }
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 ListCollectionsUsingCommandOperation(databaseNamespace, _messageEncoderSettings); var result = ExecuteOperation(subject, async); var list = ReadCursorToEnd(result, async); list.Should().HaveCount(0); }
public void Execute_should_return_the_expected_result( [Values(false, true)] bool async) { var subject = new ListCollectionsUsingCommandOperation(_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 ListCollectionsUsingCommandOperation(_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(); EnsureCollectionsExist(); int batchSize = 1; var subject = new ListCollectionsUsingCommandOperation(_databaseNamespace, _messageEncoderSettings) { BatchSize = batchSize }; using (var cursor = ExecuteOperation(subject, async) as AsyncCursor <BsonDocument>) { cursor._batchSize().Should().Be(batchSize); } }
public void CreateCommand_should_return_expected_result(string filterString, bool?nameOnly, string expectedCommand) { var filter = filterString == null ? null : BsonDocument.Parse(filterString); var subject = new ListCollectionsUsingCommandOperation(_databaseNamespace, _messageEncoderSettings) { Filter = filter, NameOnly = nameOnly }; var result = subject.CreateOperation(); result.Command.Should().Be(expectedCommand); result.DatabaseNamespace.Should().BeSameAs(subject.DatabaseNamespace); result.ResultSerializer.Should().BeSameAs(BsonDocumentSerializer.Instance); result.MessageEncoderSettings.Should().BeSameAs(subject.MessageEncoderSettings); }
public static ReadCommandOperation <BsonDocument> CreateOperation(this ListCollectionsUsingCommandOperation obj) => (ReadCommandOperation <BsonDocument>)Reflector.Invoke(obj, nameof(CreateOperation));