Mongo2Go main entry point
Inheritance: IDisposable
 internal static void CreateConnection()
 {
     Runner = MongoDbRunner.Start();
     var server = MongoServer.Create(Runner.ConnectionString);
     var database = server.GetDatabase("IntegrationTest");
     Collection = database.GetCollection<Post>("TestCollection");
 }
        public void Start()
        {
            _runner = MongoDbRunner.StartForDebugging();
            _runner.Import(DatabaseName, MongoDbNoteRepository.CollectionNotes, @"..\App_Data\" + MongoDbNoteRepository.CollectionNotes + ".json", true);
            _runner.Import(DatabaseName, MongoDbNoteRepository.CollectionCategories, @"..\App_Data\" + MongoDbNoteRepository.CollectionCategories + ".json", true);

            ConnectionString = _runner.ConnectionString;
        }
Ejemplo n.º 3
0
 public static HangfireDbContext CreateDbContext(string dbName = null)
 {
     if (_runner == null)
     {
         _runner = MongoDbRunner.Start(singleNodeReplSet: true);
     }
     return(new HangfireDbContext(_runner.ConnectionString, dbName ?? GetDatabaseName()));
 }
Ejemplo n.º 4
0
        public static MongoStorage CreateStorage(MongoStorageOptions storageOptions, string databaseName = null)
        {
            if (_runner == null)
            {
                _runner = MongoDbRunner.Start(singleNodeReplSet: true);
            }
            var mongoClientSettings = MongoClientSettings.FromConnectionString(_runner.ConnectionString);

            return(new MongoStorage(mongoClientSettings, databaseName ?? GetDatabaseName(), storageOptions));
        }
        public void Setup()
        {
            _runner = MongoDbRunner.Start();
            var mongoUrlBuilder = new MongoUrlBuilder(_runner.ConnectionString);
            mongoUrlBuilder.DatabaseName = "AutomatedTest";

            //setup mongo database
            var client = new MongoClient(mongoUrlBuilder.ToMongoUrl());
            Database = client.GetDatabase(mongoUrlBuilder.DatabaseName);
            Collection = Database.GetCollection<RootEntity>("Root");
            ContainsNotProvidedTagsEntityId = ObjectId.GenerateNewId();
            SubEntityId = ObjectId.GenerateNewId();

            //add mock data
            var entities = new List<RootEntity>()
            {
                new RootEntity()
                {
                    Id = ObjectId.GenerateNewId(),
                    Tags = new List<string>() {"tag1"},
                    SubCollection = new List<SubEntity>()
                    {
                        new SubEntity()
                        {
                            Id = SubEntityId
                        }
                    }
                },
                new RootEntity()
                {
                    Id = ContainsNotProvidedTagsEntityId,
                    Tags = new List<string>() {"tag1", "tag2"},
                    SubCollection = new List<SubEntity>()
                    {
                        new SubEntity()
                        {
                            Id = SubEntityId
                        }
                    }
                }
            };
            Collection.InsertManyAsync(entities).Wait();
        }
Ejemplo n.º 6
0
 public ConnectionUtils(IMessageSink messageSink) : base(messageSink)
 {
     _runner = MongoDbRunner.Start(singleNodeReplSet: true);
     DisposalTracker.Add(_runner);
 }