Example #1
0
        public CollectionFixture()
        {
            var builder = new ConfigurationBuilder()
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile("appsettings.testing.json", optional: true);

            configuration = builder.Build();

            var connectionString = configuration.GetSection("Data:MongoDb:ConnectionString").Value;

            ClassMapHelper.RegisterConventionPacks();

            var mongoUrl = new MongoUrl(connectionString);
            var settings = MongoClientSettings.FromUrl(mongoUrl);

            settings.SslSettings = new SslSettings
            {
                EnabledSslProtocols = SslProtocols.Tls12
            };

            client       = new MongoClient(settings);
            databaseName = configuration.GetSection("Data:MongoDb:Database").Value;
            database     = client.GetDatabase(databaseName);

            CreateCollections();
            InitializeDatabase();
        }
        public CollectionFixture()
        {
            var builder = new ConfigurationBuilder()
                          .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
                          .AddJsonFile("appsettings.testing.json", optional: true);

            configuration = builder.Build();
            var connectionString = configuration.GetSection("Data:MongoDb:ConnectionString").Value;

            ClassMapHelper.RegisterConventionPacks();

            databaseName = configuration.GetSection("Data:MongoDb:Database").Value;
            client       = new MongoClient(connectionString);
            database     = client.GetDatabase(databaseName);

            InitializeDatabase();
        }
Example #3
0
 static MongoDbRepository()
 {
     ClassMapHelper.RegisterConventionPacks();
     ClassMapHelper.SetupClassMap <TEntity, TId>();
 }