Esempio n. 1
0
        public void FixtureSetup()
        {
            this.unityContainer = new UnityContainer();
            IoC.Initialize(
                (x, y) => this.unityContainer.RegisterType(x, y),
                (x, y) => this.unityContainer.RegisterInstance(x, y),
                (x) => { return(unityContainer.Resolve(x)); },
                (x) => { return(unityContainer.ResolveAll(x)); });

            // Context Factory
            EFUnitOfWorkFactory ctxFactory = new EFUnitOfWorkFactory(this.ConnectionString(), typeof(DomainContext));

            if (!ctxFactory.DatabaseExists())
            {
                ctxFactory.CreateDatabase();
            }

            ctxFactory.ValidateDatabaseSchema();

            this.unityContainer.RegisterInstance <IDatabaseManager>(ctxFactory);
            this.unityContainer.RegisterInstance <IUnitOfWorkFactory>(ctxFactory);

            this.unityContainer.RegisterType <DbContext, DomainContext>(new InjectionFactory((c) =>
            {
                return(ctxFactory.CurrentDbContext);
            }));

            // Repositories
            this.unityContainer.RegisterType <IEntityARepository, EntityAEFRepository>(new PerResolveLifetimeManager());
            this.unityContainer.RegisterType <IEntityBRepository, EntityBEFRepository>(new PerResolveLifetimeManager());

            ApplicationContext.User =
                new CorePrincipal(new CoreIdentity("cmendible", "hexa.auth", "*****@*****.**"), new string[] { });
        }
Esempio n. 2
0
        public void FixtureSetup()
        {
            this.unityContainer = new UnityContainer();
            IoC.Initialize(
                (x, y) => this.unityContainer.RegisterType(x, y),
                (x, y) => this.unityContainer.RegisterInstance(x, y),
                (x) => { return unityContainer.Resolve(x); },
                (x) => { return unityContainer.ResolveAll(x); });

            // Context Factory
            EFUnitOfWorkFactory ctxFactory = new EFUnitOfWorkFactory(this.ConnectionString(), typeof(DomainContext));

            if (!ctxFactory.DatabaseExists())
            {
                ctxFactory.CreateDatabase();
            }

            ctxFactory.ValidateDatabaseSchema();

            this.unityContainer.RegisterInstance<IDatabaseManager>(ctxFactory);
            this.unityContainer.RegisterInstance<IUnitOfWorkFactory>(ctxFactory);

            this.unityContainer.RegisterType<DbContext, DomainContext>(new InjectionFactory((c) =>
            {
                return ctxFactory.CurrentDbContext;
            }));

            // Repositories
            this.unityContainer.RegisterType<IEntityARepository, EntityAEFRepository>(new PerResolveLifetimeManager());
            this.unityContainer.RegisterType<IEntityBRepository, EntityBEFRepository>(new PerResolveLifetimeManager());

            ApplicationContext.User =
                new CorePrincipal(new CoreIdentity("cmendible", "hexa.auth", "*****@*****.**"), new string[] { });
        }