Наследование: NHibernateRepository, IFooRepository
Пример #1
0
        protected override void Context()
        {
            base.Context();

            try
            {
                UnitOfWork.Configure(_config);
                //DepCon.RegisterType<IUnitOfWork, MockUnitOfWork>();
                fooRepo = new MockFooRepo();
                fooRepo.Something();
            }
            catch (NoUnitOfWorkException ex)
            {
                caughtException = ex;
            }
        }
Пример #2
0
        protected override void Context()
        {
            base.Context();

            foo = new MockFooRepo();

            ObjectFactory.Initialize(
                factory => factory
                .ForRequestedType <IFooRepository>().TheDefault.IsThis(foo));

            UnitOfWork.Start(() =>
            {
                Transaction.Begin();
                NHibernateConfig.GenerateSchema();
                Repository <IFooRepository> .Do.Something();
                Transaction.Commit();
            });
        }
        protected override void Context()
        {
            base.Context();

            //DepCon.ClearRegistrations();
            fooRepo = new MockFooRepo();
            //DepCon.RegisterInstance<IFooRepository>(fooRepo);
            ObjectFactory.Initialize(
                factory => factory
                .ForRequestedType <IFooRepository>().TheDefault.IsThis(fooRepo));

            IDictionary <string, string> properties = new Dictionary <string, string>
            {
                { "connection.driver_class", "NHibernate.Driver.SQLite20Driver" },
                { "dialect", "NHibernate.Dialect.SQLiteDialect" },
                { "connection.provider", "NHibernate.Connection.DriverConnectionProvider" },
                {
                    "connection.connection_string",
                    @"Data Source=FooDb.s3db"
                },
                { "connection.release_mode", "on_close" },
                { "proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle" }
            };

            NHibernateConfig config = new NHibernateConfig(properties, _repositoryFactory, _uowStorage, typeof(Foo).Assembly);

            UnitOfWork.Configure(config);
            UnitOfWork.Start(() =>
            {
                Transaction.Begin();
                Repository <IFooRepository> .Do.Something();
                Transaction.Rollback();
            });
            UnitOfWork.Start(() =>
            {
                foo = fooRepo.CheckForIt();
            });
        }
        protected override void Context()
        {
            base.Context();

            //DepCon.ClearRegistrations();
            fooRepo = new MockFooRepo();
            //DepCon.RegisterInstance<IFooRepository>(fooRepo);
            ObjectFactory.Initialize(
                factory => factory
                    .ForRequestedType<IFooRepository>().TheDefault.IsThis(fooRepo));

            IDictionary<string, string> properties = new Dictionary<string, string>
            {
                {"connection.driver_class", "NHibernate.Driver.SQLite20Driver"},
                {"dialect", "NHibernate.Dialect.SQLiteDialect"},
                {"connection.provider", "NHibernate.Connection.DriverConnectionProvider"},
                {
                    "connection.connection_string",
                    @"Data Source=FooDb.s3db"
                    },
                {"connection.release_mode", "on_close"},
                {"proxyfactory.factory_class", "NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"}
            };

            NHibernateConfig config = new NHibernateConfig(properties, _repositoryFactory, _uowStorage, typeof(Foo).Assembly );
            UnitOfWork.Configure(config);
            UnitOfWork.Start(() =>
            {
                Transaction.Begin();
                Repository<IFooRepository>.Do.Something();
                Transaction.Rollback();
            });
            UnitOfWork.Start(() =>
             		{
                foo = fooRepo.CheckForIt();
             		});
        }