Exemple #1
0
        public static ISession OpenSession()
        {
            string connStr        = ConfigurationManager.ConnectionStrings["testdb"].ConnectionString;
            var    engine         = DbRegistry.GetEngine(DatabaseType.SqlServer);
            var    sessionFactory = engine.CreateSessionFactory(connStr);

            sessionFactory.MapEntitiesWithAnnonations(typeof(NotNullEntity).Assembly);
            return(sessionFactory.OpenSession());
        }
Exemple #2
0
        public void MapEntitiesWithAnnonations(Type entityType)
        {
            var engine         = DbRegistry.GetEngine(DatabaseType.SqlServer);
            var connStr        = ConfigurationManager.ConnectionStrings["tempdb"].ConnectionString;
            var sessionFactory = engine.CreateSessionFactory(connStr);

            sessionFactory.MapEntitiesWithAnnonations(typeof(NotNullEntity).Assembly);

            Assert.IsNotNull(sessionFactory.GetMapper(entityType));
        }
        /// <summary>
        /// Initialize
        /// </summary>
        /// <param name="dbType"></param>
        /// <param name="connectionName"></param>
        /// <param name="entityAssembly">Assembly that contains entity definitions</param>
        /// <param name="repositoryAssembly">Assembly that contains repository implementations</param>
        protected FrameworkDatabase(DatabaseType dbType, string connectionName, Assembly entityAssembly,
                                    Assembly repositoryAssembly)
        {
            Expect.IsNotBlank(connectionName, nameof(connectionName));
            Expect.IsNotNull(entityAssembly, nameof(entityAssembly));
            Expect.IsNotNull(repositoryAssembly, nameof(repositoryAssembly));

            _connectionName     = connectionName;
            _entityAssembly     = entityAssembly;
            _repositoryAssembly = repositoryAssembly;

            Engine = DbRegistry.GetEngine(dbType);
        }
        public void GetEngine_SupportedType_ShouldReturnEngine(DatabaseType type)
        {
            var engine = DbRegistry.GetEngine(type);

            Assert.IsNotNull(engine);
        }
 public void GetEngine_UnsupportedType_Throw()
 {
     Assert.Throws <NotSupportedException>(() => DbRegistry.GetEngine(DatabaseType.Unknown));
 }