public void TestInitialize()
 {
     Environment.CurrentDirectory = AppDomain.CurrentDomain.BaseDirectory;
     InitializeNHibernateAndIoC(PersistenceFramework.NHibernate,
                                Path.GetFullPath(@"Repository\Windsor.config"),
                                MappingInfo.FromAssemblyContaining <Parent>());
     CurrentContext.CreateUnitOfWork();
 }
Exemple #2
0
 protected void InitializeNHibernateAndIoC(string rhinoContainerPath,
                                           DatabaseEngine databaseEngine,
                                           string databaseName)
 {
     InitializeNHibernateAndIoC(FrameworkToTest,
                                rhinoContainerPath,
                                databaseEngine,
                                databaseName,
                                MappingInfo.FromAssemblyContaining <AREntity>());
 }
        public void OneTimeTestInitialize()
        {
            //turn on log4net logging (and supress output to console)
            BasicConfigurator.Configure(new MemoryAppender());

            string path = Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"UoW\Windsor.config"));

            InitializeNHibernateAndIoC(PersistenceFramework.NHibernate,
                                       path,
                                       DatabaseEngine.MsSqlCe,
                                       MappingInfo.FromAssemblyContaining <SimpleObject>());
        }
Exemple #4
0
        public void CanInitializeWithFluentInterfaceAndContainerInstance()
        {
            MappingInfo       mappingInfo = MappingInfo.FromAssemblyContaining <AREntity>();
            IWindsorContainer container   = new WindsorContainer();

            container.AddFacility("nh",
                                  new NHibernateUnitOfWorkFacility(
                                      new NHibernateUnitOfWorkFacilityConfig(Assembly.GetAssembly(typeof(AREntity)))));

            Initialize(PersistenceFramework.NHibernate, mappingInfo).AndIoC(container);

            Assert.AreSame(container, CurrentContext.RhinoContainer);
        }
        public void CanSwitchBetweenPersistentFrameworksWithinSameTest()
        {
            MappingInfo mappingInfo = MappingInfo.FromAssemblyContaining <AREntity>();

            InitializeNHibernateAndIoC(PersistenceFramework.NHibernate,
                                       NHibernateWindsorFilePath,
                                       DatabaseEngine.SQLite,
                                       "",
                                       mappingInfo);
            VerifyCanCreateUseAndDisposeUnitOfWork();

            InitializeNHibernateAndIoC(PersistenceFramework.ActiveRecord,
                                       ActiveRecordWindsorFilePath,
                                       DatabaseEngine.SQLite,
                                       "",
                                       mappingInfo);
            VerifyCanCreateUseAndDisposeUnitOfWork();
        }
Exemple #6
0
        protected void VerifyCanCreateUnitOfWorkContextFor(PersistenceFramework framework,
                                                           string rhinoContainerPath,
                                                           DatabaseEngine databaseEngine,
                                                           string databaseName)
        {
            int nextContextPosition = Contexts.Count;

            //creates the UnitOfWorkContext
            MappingInfo mappingInfo = MappingInfo.FromAssemblyContaining <AREntity>();

            InitializeNHibernateAndIoC(framework,
                                       rhinoContainerPath,
                                       databaseEngine,
                                       databaseName,
                                       mappingInfo);

            UnitOfWorkTestContext context = Contexts[nextContextPosition];

            Assert.AreEqual(framework, context.Framework);
            if (rhinoContainerPath != null)
            {
                Assert.AreEqual(rhinoContainerPath, context.RhinoContainerConfigPath);
            }
            else
            {
                Assert.IsEmpty(context.RhinoContainerConfigPath);
            }
            Assert.AreEqual(databaseEngine, context.DatabaseEngine);
            if (string.IsNullOrEmpty(databaseName))
            {
                Assert.AreEqual(
                    NHibernateInitializer.DeriveDatabaseNameFrom(databaseEngine, mappingInfo.MappingAssemblies[0]),
                    context.DatabaseName);
            }
            else
            {
                Assert.AreEqual(databaseName, context.DatabaseName);
            }

            Assert.AreEqual(CurrentContext,
                            context,
                            "Context just built has been assigned to CurrentContext");
        }
        public void OneTimeTestInitialize()
        {
            string path = Path.GetFullPath(@"Repository\Windsor.config");

            InitializeNHibernateAndIoC(PersistenceFramework.NHibernate, path, MappingInfo.FromAssemblyContaining <Parent>());
        }
 public void OneTimeTestInitialize()
 {
     InitializeNHibernateAndIoC(PersistenceFramework.NHibernate, "", DatabaseEngine.SQLite, MappingInfo.FromAssemblyContaining <SMS>());
 }
 public void OneTimeTestInitialize()
 {
     InitializeNHibernateAndIoC(PersistenceFramework.NHibernate, NHibernateWindsorFilePath, DatabaseEngine.MsSql2005,
                                "Test", MappingInfo.FromAssemblyContaining <Mail>());
 }