public void CreateCreateChunksCollectionIndexesOperation_should_return_expected_result(
            [Values(1, 2)]
            int databaseW,
            [Values(null, 1, 2)]
            int? bucketW)
        {
            var bucketWriteConcern = bucketW.HasValue ? new WriteConcern(bucketW.Value) : null;
            var options = new GridFSBucketOptions { WriteConcern = bucketWriteConcern };
            var subject = CreateSubject(options);
            var databaseWriteConcern = new WriteConcern(databaseW);
            var mockDatabase = Mock.Get(subject.Database);
            var databaseSettings = new MongoDatabaseSettings { WriteConcern = databaseWriteConcern };
            mockDatabase.SetupGet(d => d.Settings).Returns(databaseSettings);

            var result = subject.CreateCreateChunksCollectionIndexesOperation();

            result.CollectionNamespace.CollectionName.Should().Be("fs.chunks");
            result.MessageEncoderSettings.Should().NotBeNull();
            result.Requests.Should().NotBeNull();
            result.WriteConcern.Should().BeSameAs(bucketWriteConcern ?? databaseWriteConcern);
        }
예제 #2
0
 public IMongoDatabase GetDatabase(string name, MongoDatabaseSettings settings = null)
 {
     return(new MockMongoDatabase());
 }
예제 #3
0
        /// <summary>
        /// Get the email client using connection information from the test run configuration
        /// </summary>
        /// <returns>The email connection</returns>
        public static IMongoCollection <T> GetCollection <T>(string connectionString, string databaseString, MongoDatabaseSettings settings, string collectionString)
        {
            var connection = new MongoClient(new MongoUrl(connectionString));
            var database   = connection.GetDatabase(databaseString, settings);

            return(database.GetCollection <T>(collectionString));
        }
예제 #4
0
 public IMongoDatabase GetDatabase(string name, MongoDatabaseSettings settings = null)
 => databases.GetOrAdd(name, n => new InMemoryDatabase(this, n, iocContainer));
예제 #5
0
 public abstract IMongoDatabase GetDatabase(string name, MongoDatabaseSettings settings        = null);
예제 #6
0
        //public Connect(DBConfigration configuration)
        //{
        //    string mongoConnectionString = configuration.ConnectionString;
        //    string mongoDatabase = configuration.Database;
        //    this.Client = new MongoClient(mongoConnectionString);
        //    this.DataBase = this.Client.GetDatabase(mongoDatabase, null);
        //    this.DatabaseSettings = this.DataBase.Settings;
        //}

        //public Connect(DBConfigration configuration, MongoDatabaseSettings databaseSettings)
        //{
        //    string mongoConnectionString = configuration.ConnectionString;
        //    string mongoDatabase = configuration.Database;
        //    this.Client = new MongoClient(mongoConnectionString);
        //    this.DataBase = this.Client.GetDatabase(mongoDatabase, databaseSettings);
        //    this.DatabaseSettings = this.DataBase.Settings;
        //}
        public Connect(MongoUrl mongoUrl)
        {
            this.Client           = new MongoClient(mongoUrl);
            this.DataBase         = this.Client.GetDatabase(mongoUrl.DatabaseName);
            this.DatabaseSettings = this.DataBase.Settings;
        }
예제 #7
0
 private void JustDecompileGenerated_set_DatabaseSettings(MongoDatabaseSettings value)
 {
     this.JustDecompileGenerated_DatabaseSettings_k__BackingField = value;
 }
예제 #8
0
 public virtual IMongoDatabase GetDatabase(string name, MongoDatabaseSettings settings      = null) => throw new NotImplementedException();
예제 #9
0
 public MongoDbContextOptions(string connectionString, string databaseName = null, MongoDatabaseSettings settings = null)
     : base(connectionString, databaseName, settings)
 {
 }
예제 #10
0
 public IMongoDatabase GetDatabase(string name, MongoDatabaseSettings settings = null)
 {
     return(_client.GetDatabase(name, settings).AsTransactionDatabase());
 }
예제 #11
0
 /// <summary>
 /// 获取数据库
 /// </summary>
 /// <param name="name"></param>
 /// <param name="settings"></param>
 /// <returns></returns>
 public virtual IMongoDatabase GetDatabase(string name, MongoDatabaseSettings settings = null)
 {
     return(Context.GetDatabase(name, settings));
 }
 public IMongoDatabase GetDatabase(string name, MongoDatabaseSettings settings = null) => _mongoClient.GetDatabase(name, settings);
예제 #13
0
 public Connect(IMongoDatabase mongoDatabase)
 {
     this.Client           = mongoDatabase.Client;
     this.DataBase         = mongoDatabase;
     this.DatabaseSettings = mongoDatabase.Settings;
 }
예제 #14
0
 public Connect(IMongoClient mongoClient, string databaseName, MongoDatabaseSettings databaseSettings = null)
 {
     this.Client           = mongoClient;
     this.DataBase         = this.Client.GetDatabase(databaseName, databaseSettings);
     this.DatabaseSettings = databaseSettings;
 }
 public MongoDbStoreStrategy(string databasename, MongoDatabaseSettings settings)
 {
     MongoDB.Driver.MongoClient client = new MongoDB.Driver.MongoClient();
     database = client.GetDatabase(databasename, settings);
 }
예제 #16
0
 public static Builder Create(string connectionString, string database, MongoDatabaseSettings settings = null)
 => new Builder(connectionString, database, settings);
예제 #17
0
 public override IMongoDatabase GetDatabase(string name, MongoDatabaseSettings settings = null)
 {
     return(_databases.GetOrAdd(name, CreateDatabase));
 }
예제 #18
0
 public IMongoDatabase GetDatabase(string name, MongoDatabaseSettings settings = null)
 {
     return(wrapped.GetDatabase(name, settings));
 }
예제 #19
0
 public MongoRepository Connect(string databaseName, MongoDatabaseSettings mongoDatabaseSettings = null)
 {
     _MongoDatabase = _MongoClient.GetDatabase(databaseName, mongoDatabaseSettings);
     return(this);
 }
예제 #20
0
 public MongoDbContext(string connection, MongoDatabaseSettings settings) : this(connection)
 {
     var mongoUrl = new MongoUrl(connection);
     Database = Client.GetDatabase(mongoUrl.DatabaseName, settings);
 }
예제 #21
0
 public Connect(MongoDatabaseSettings databaseSettings)
 {
     this.Client           = new MongoClient(ConfigurationManager.AppSettings["MongoConnectionString"]);
     this.DataBase         = this.Client.GetDatabase(ConfigurationManager.AppSettings["MongoDatabase"], databaseSettings);
     this.DatabaseSettings = this.DataBase.Settings;
 }
        public void CreateDropCollectionOperation_should_return_expected_result(
            [Values(1, 2)]
            int databaseW,
            [Values(null, 1, 2)]
            int? bucketW)
        {
            var bucketWriteConcern = bucketW.HasValue ? new WriteConcern(bucketW.Value) : null;
            var options = new GridFSBucketOptions { WriteConcern = bucketWriteConcern };
            var subject = CreateSubject(options);
            var databaseWriteConcern = new WriteConcern(databaseW);
            var mockDatabase = Mock.Get(subject.Database);
            var databaseSettings = new MongoDatabaseSettings { WriteConcern = databaseWriteConcern };
            mockDatabase.SetupGet(d => d.Settings).Returns(databaseSettings);
            var collectionNamespace = new CollectionNamespace(subject.Database.DatabaseNamespace, "collection");
            var messageEncoderSettings = new MessageEncoderSettings();

            var result = subject.CreateDropCollectionOperation(collectionNamespace, messageEncoderSettings);

            result.CollectionNamespace.Should().BeSameAs(collectionNamespace);
            result.MessageEncoderSettings.Should().BeSameAs(messageEncoderSettings);
            result.WriteConcern.Should().BeSameAs(bucketWriteConcern ?? databaseWriteConcern);
        }
예제 #23
0
 public Connect(string connectionString, string databaseName, MongoDatabaseSettings databaseSettings)
 {
     this.Client           = new MongoClient(connectionString);
     this.DataBase         = this.Client.GetDatabase(databaseName, databaseSettings);
     this.DatabaseSettings = databaseSettings;
 }
예제 #24
0
 public IMongoDatabase GetDatabase(MongoDatabaseSettings settings = null)
 {
     return(server.GetDatabase(dbName, settings));
 }