Пример #1
0
 public void SetUp()
 {
     _Container = new Container();
     _Container.Register <MyService>(Reuse.Singleton);
     _Container.AddNLogLogging();
     _Container.AddAutoTx();
 }
Пример #2
0
        private static Container GetTxContainer()
        {
            var c = new Container();

            c.AddNLogLogging();
            c.AddAutoTx();
            return(c);
        }
Пример #3
0
 public void SetUp()
 {
     container = new Container();
     container.AddNLogLogging();
     container.Register <INHibernateInstaller, ExampleInstaller>(Reuse.Singleton, FactoryMethod.ConstructorWithResolvableArguments);
     container.Register <ThreadedService>(Reuse.Transient);
     container.AddAutoTx();
     container.AddNHibernate(AmbientTransactionOption.Enabled);
 }
Пример #4
0
 public void SetUp()
 {
     container = new Container();
     container.AddNLogLogging();
     container.Register <IEFCoreInstaller, ExampleInstaller>(Reuse.Singleton, FactoryMethod.ConstructorWithResolvableArguments);
     container.Register <ThreadedService>(Reuse.Transient);
     container.AddAutoTx();
     container.AddEFCore();
 }
 public void SetUp()
 {
     _Container = new Container();
     _Container.Register <IServiceWithTransaction, SimpleServiceWithTransaction>(Reuse.Singleton);
     _Container.Register <SimpleServiceWithTransaction>(Reuse.Singleton);
     _Container.Register <EmptyServiceWithInfo>(Reuse.Singleton);
     _Container.Register <ServiceWithParentInfo>(Reuse.Transient);
     _Container.AddAutoTx();
 }
Пример #6
0
        public void Register_Then_AddFacility_ThenInvokeTransactionalMethod()
        {
            var container = new Container();

            container.Register <MyService>(Reuse.Transient);
            container.AddAutoTx();

            // this throws if we have not implemented this feature
            using (var s = container.ResolveScope <MyService>())
                s.Service.VerifyInAmbient();
        }
Пример #7
0
        public void SetUp()
        {
            var c = new Container();

            c.AddNLogLogging();
            c.Register <IEFCoreInstaller, ExampleInstaller>(Reuse.Singleton, FactoryMethod.ConstructorWithResolvableArguments);
            c.Register <SimpleService>(Reuse.Singleton);
            c.AddAutoTx();
            c.AddEFCore();
            _Container = c;
        }
Пример #8
0
        public void Register_Run()
        {
            c.Register <ServiceWithProtectedMethodInTransaction>(Reuse.Singleton);

            c.AddAutoTx();
            c.AddEFCore();

            Assert.That(c.IsRegistered(typeof(ITransactionManager)));

            using (var s = c.ResolveScope <ServiceWithProtectedMethodInTransaction>())
            {
                s.Service.Do();
            }
        }
Пример #9
0
        private void AssertOrder(Container c)
        {
            c.AddAutoTx();

            try
            {
                c.AddNHibernate();
                Assert.Fail("no exception thrown");
            }
            catch (ApplicationException ex)
            {
                Assert.That(ex.Message, Is.EqualTo("C1"));
            }
        }
Пример #10
0
        public void Register_Run_AmbientEnabled(AmbientTransactionOption ambientTransaction)
        {
            c.Register <ServiceWithProtectedMethodInTransaction>(Reuse.Singleton);

            c.AddAutoTx();
            c.AddNHibernate(ambientTransaction);

            Assert.That(c.IsRegistered(typeof(ITransactionManager)));

            using (var s = c.ResolveScope <ServiceWithProtectedMethodInTransaction>())
            {
                s.Service.Do();
            }
        }
Пример #11
0
        public static Container Create(AmbientTransactionOption ambientTransaction)
        {
            var container = new Container();

            container.UseInstance <INHibernateInstaller>(new ExampleInstaller(new ThrowingInterceptor()));

            container.Register <Test>(Reuse.Transient);
            container.Register <NestedTransactionService>(Reuse.Transient);

            container.AddAutoTx();
            container.AddNHibernate(ambientTransaction);

            return(container);
        }
Пример #12
0
        private Container GetContainer()
        {
            var container = new Container();

            container.AddNLogLogging();
            container.Register <IPerTxServiceFactory, ServiceFactory>(Reuse.Singleton, serviceKey: "per-tx-session.factory");
            container.Register <IPerTxService>(AutoTxReuse.PerTransaction, Made.Of(() => CreatePerTransactionService(container)));
            container.Register <Service>(Reuse.Singleton);
            container.Register <ServiceWithDirectDep>(Reuse.Singleton);

            container.AddAutoTx();

            return(container);
        }
        private IContainer SetUpContainer()
        {
            var container = new Container();

            container.Register <IUnitOfWork, UnitOfWorkImpl>(AutoTxReuse.PerTransaction);
            container.Register <IRepo, Repo>(Reuse.Transient);
            container.Register <IMessageHandler <MyMessage>, ServiceClass>(Reuse.Singleton);

            container.Register <IBus, BusImpl>(Reuse.Singleton);

            container.AddAutoTx();

            return(container);
        }
Пример #14
0
        public static Container Create()
        {
            var container = new Container();

            container.Register <IEFCoreInstaller, ExampleInstaller>(Reuse.Singleton, FactoryMethod.ConstructorWithResolvableArguments);
            //container.UseInstance<INHibernateInstaller>(new ExampleInstaller(new ThrowingInterceptor())); //TODO remove this line

            container.Register <Test>(Reuse.Transient);
            container.Register <NestedTransactionService>(Reuse.Transient);

            container.AddAutoTx();
            container.AddEFCore();

            return(container);
        }
        private static Container GetContainer()
        {
            var c = new Container();

            c.Register <INHibernateInstaller, ExampleInstaller>(Reuse.Singleton);

            c.AddNLogLogging();
            c.AddAutoTx();
            c.AddNHibernate(AmbientTransactionOption.Enabled);

            c.Register <ReproClass>(Reuse.Singleton);

            Assert.That(c.IsRegistered(typeof(ITransactionManager)));

            return(c);
        }
        public void NonNullInterceptor()
        {
            var w = new Container();

            w.UseInstance <INHibernateInstaller>(new ExampleInstaller(new ThrowingInterceptor()));
            w.AddAutoTx();
            w.AddNHibernate();

            var session = w.Resolve <ISession>(w.Resolve <INHibernateInstaller>().SessionFactoryKey + NHibernateFacility.SessionTransientSuffix);

            using (session)
            {
                Assert.That(session.GetSessionImplementation().Interceptor, Is.Not.Null);
            }
            w.Release(session);
        }
        private static Container GetContainer(AmbientTransactionOption ambientTransaction)
        {
            var c = new Container();

            c.Register <INHibernateInstaller, ExampleInstaller>(Reuse.Singleton, FactoryMethod.ConstructorWithResolvableArguments);
            c.Register <ServiceUsingPerTransactionSessionLifestyle>(Reuse.Transient);
            c.Register <TearDownService>(Reuse.Transient);

            c.AddNLogLogging();
            c.AddAutoTx();
            c.AddNHibernate(ambientTransaction);

            Assert.That(c.IsRegistered(typeof(ITransactionManager)));

            return(c);
        }
Пример #18
0
        public void Cannot_Register_Class_Without_Virtual_Method()
        {
            var c = new Container();

            c.Register <FaultyComponent>(Reuse.Singleton);

            try
            {
                c.AddAutoTx();
                Assert.Fail("invalid component registration should be noted.");
            }
            catch (AutoTxFacilityException ex)
            {
                Assert.That(ex.Message.Contains("FaultyMethod"));
                Assert.That(ex.Message.Contains("virtual"));
            }
        }
Пример #19
0
        public void CacheFile_Is_Created()
        {
#if NETCOREAPP
            _Logger.Warn("System.Type serializing doesn't work on .NET Core platform");
            Assert.Ignore("System.Type serializing doesn't work on .NET Core platform");
#endif

            using (var c = new Container())
            {
                c.Register <INHibernateInstaller, PersistingInstaller>(Reuse.Singleton);

                c.AddNLogLogging();
                c.AddAutoTx();
                c.AddNHibernate();

                Assert.That(File.Exists(PersistingInstaller.SerializedConfigFile), "Could not find serialized cache file");
            }
        }
 public void SetUp()
 {
     _Container = new Container();
     _Container.Register <InheritedMyService>(Reuse.Singleton);
     _Container.AddAutoTx();
 }
 public void SetUp()
 {
     _Container = new Container();
     _Container.Register <ConcreteService>(Reuse.Singleton);
     _Container.AddAutoTx();
 }