private FindOperation <TResult> CreateAggregateToCollectionFindOperation <TResult>(BsonDocument outStage, IBsonSerializer <TResult> resultSerializer, AggregateOptions options) { CollectionNamespace outputCollectionNamespace; var stageName = outStage.GetElement(0).Name; switch (stageName) { case "$out": { var outValue = outStage[0]; DatabaseNamespace outputDatabaseNamespace; string outputCollectionName; if (outValue.IsString) { outputDatabaseNamespace = _databaseNamespace; outputCollectionName = outValue.AsString; } else { outputDatabaseNamespace = new DatabaseNamespace(outValue["db"].AsString); outputCollectionName = outValue["coll"].AsString; } outputCollectionNamespace = new CollectionNamespace(outputDatabaseNamespace, outputCollectionName); } break; case "$merge": { var mergeArguments = outStage[0].AsBsonDocument; DatabaseNamespace outputDatabaseNamespace; string outputCollectionName; var into = mergeArguments["into"]; if (into.IsString) { outputDatabaseNamespace = _databaseNamespace; outputCollectionName = into.AsString; } else { outputDatabaseNamespace = new DatabaseNamespace(into["db"].AsString); outputCollectionName = into["coll"].AsString; } outputCollectionNamespace = new CollectionNamespace(outputDatabaseNamespace, outputCollectionName); } break; default: throw new ArgumentException($"Unexpected stage name: {stageName}."); } // because auto encryption is not supported for non-collection commands. // So, an error will be thrown in the previous CreateAggregateToCollectionOperation step. // However, since we've added encryption configuration for CreateAggregateToCollectionOperation operation, // it's not superfluous to also add it here var messageEncoderSettings = GetMessageEncoderSettings(); return(new FindOperation <TResult>(outputCollectionNamespace, resultSerializer, messageEncoderSettings) { BatchSize = options.BatchSize, Collation = options.Collation, MaxTime = options.MaxTime, ReadConcern = _settings.ReadConcern, RetryRequested = _client.Settings.RetryReads }); }
public void IsValid_should_return_the_correct_result(string name, bool valid) { DatabaseNamespace.IsValid(name).Should().Be(valid); }
public void DatabaseName_should_report_the_provided_database_name() { var subject = new DatabaseNamespace("test"); subject.DatabaseName.Should().Be("test"); }
public void ToString_should_return_the_name() { var subject = new DatabaseNamespace("test"); subject.ToString().Should().Be("test"); }
public void DatabaseUsingTestSetUp() { _databaseNamespace = new DatabaseNamespace(GetDatabaseName()); }
public CollectionNamespace(DatabaseNamespace databaseNamespace, string collectionName) { _databaseNamespace = Ensure.IsNotNull(databaseNamespace, "databaseNamespace"); _collectionName = Ensure.That(collectionName, IsValid, "collectionName", "Collection names must be non-empty and not contain the null character."); }
/// <summary> /// Initializes a new instance of the <see cref="CollectionNamespace"/> class. /// </summary> /// <param name="databaseNamespace">The database namespace.</param> /// <param name="collectionName">The name of the collection.</param> public CollectionNamespace(DatabaseNamespace databaseNamespace, string collectionName) { _databaseNamespace = Ensure.IsNotNull(databaseNamespace, nameof(databaseNamespace)); _collectionName = Ensure.That(collectionName, IsValid, nameof(collectionName), "Collection names must be non-empty and not contain the null character."); _fullName = _databaseNamespace.DatabaseName + "." + _collectionName; }
public void SuiteConfigurationSetUp() { __connectionString = GetConnectionString(); __databaseNamespace = GetDatabaseNamespace(); }