public virtual void OneTimeSetUp()
        {
            BsonMapper.RegisterTypeWithAutoMap <MongoModel>();

            BsonMapper.RegisterClassMaps(typeof(Character), typeof(Movement), typeof(Move), typeof(CharacterAttribute),
                                         typeof(CharacterAttributeRow));

            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appSettings.json", true, true)
                                .Build();

            string username         = configuration[ConfigurationKeys.Username];
            string password         = configuration[ConfigurationKeys.Password];
            string databaseName     = configuration[ConfigurationKeys.DatabaseName];
            string connectionString = configuration[ConfigurationKeys.DefaultConnection];

            MongoDatabase = MongoDbConnectionFactory.GetDatabaseFromAppConfig(username, password, databaseName, connectionString);
        }
        protected BaseRepositoryTests(params Type[] modelTypes)
        {
            Fixture = new Fixture();

            BsonMapper.RegisterTypeWithAutoMap <MongoModel>();
            BsonMapper.RegisterClassMaps(modelTypes);


            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appSettings.json", true, true)
                                .Build();

            string username         = configuration[ConfigurationKeys.Username];
            string password         = configuration[ConfigurationKeys.Password];
            string databaseName     = configuration[ConfigurationKeys.DatabaseName];
            string connectionString = configuration[ConfigurationKeys.DefaultConnection];

            MongoDatabase = MongoDbConnectionFactory.GetDatabaseFromAppConfig(username, password, databaseName, connectionString);
        }
Esempio n. 3
0
        private static void MapMongoDbConstructs()
        {
            //configure mongo db model mapping
            var mongoDbBsonMapper = new MongoDbBsonMapper();

            var assembliesToScanForModels = Assembly
                                            .GetExecutingAssembly()
                                            .GetReferencedAssemblies()
                                            .Where(a => a.FullName.StartsWith("FrannHammer"))
                                            .Select(Assembly.Load).ToList();

            BsonMapper.RegisterTypeWithAutoMap <MongoModel>();
            mongoDbBsonMapper.MapAllLoadedTypesDerivingFrom <MongoModel>(assembliesToScanForModels);

            //character attribute is special.. thanks to mongodb not being able to deserialize to interfaces naturally (FINE.)
            BsonMapper.RegisterClassMaps(typeof(CharacterAttribute));

            //Register IMove implementation to move implementation map
            MoveParseClassMap.RegisterType <IMove, Move>();
        }
Esempio n. 4
0
 public static void InitializeMapping()
 {
     BsonMapper.RegisterTypeWithAutoMap <MongoModel>();
     BsonMapper.RegisterClassMaps(typeof(Character), typeof(Movement), typeof(Move),
                                  typeof(CharacterAttributeRow), typeof(CharacterAttribute), typeof(UniqueData));
 }
Esempio n. 5
0
 private static void MapAllLoadedTypesDerivingFromCore <T>(Assembly assemblyToReflectOver)
 {
     Guard.VerifyObjectNotNull(assemblyToReflectOver, nameof(assemblyToReflectOver));
     BsonMapper.RegisterClassMaps(GetModelTypes <T>().ToArray());
 }