Exemplo n.º 1
0
        public void LoadProjectLoadsCorrectProject()
        {
            ISessionFactory sessionFactory = SessionFactoryFactory.CreateSessionFactory();
            TestDataFactory testDataFac = new TestDataFactory();

            var productDefinitionList = testDataFac.GenerateTestProductDefinitionList(4);
            var qaTestDefinitionList = new List<QATestDefinition>();

            foreach (ProductDefinition product in productDefinitionList)
            {
                qaTestDefinitionList.AddRange(testDataFac.GenerateTestQATestDefinitionList(product, 3));
            }

            List<Project> projectList = testDataFac.PopulateTestData(productDefinitionList, qaTestDefinitionList, 1);

            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    foreach (ProductDefinition pd in productDefinitionList)
                    {
                        session.Save(pd);
                    }
                    foreach (QATestDefinition qad in qaTestDefinitionList)
                    {
                        session.Save(qad);
                    }
                    foreach (Project pj in projectList)
                    {
                        session.Save(pj);
                    }
                    transaction.Commit();
                }
            }

            DataRetrieval dr = new DataRetrieval();
            var loadedProj = dr.GetProject(projectList[0].Id);
        }
Exemplo n.º 2
0
        public void ProjectCascadeIsStoredToDatabaseOnSave()
        {
            ISessionFactory sessionFactory = SessionFactoryFactory.CreateSessionFactory();
            TestDataFactory testDataFac = new TestDataFactory();

            var productDefinitionList = testDataFac.GenerateTestProductDefinitionList(4);
            var qaTestDefinitionList = new List<QATestDefinition>();

            foreach (ProductDefinition product in productDefinitionList)
            {
                qaTestDefinitionList.AddRange(testDataFac.GenerateTestQATestDefinitionList(product, 3));
            }

            List<Project> projectList = testDataFac.PopulateTestData(productDefinitionList,qaTestDefinitionList,2);

            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    foreach (ProductDefinition pd in productDefinitionList)
                    {
                        session.Save(pd);
                    }
                    foreach (QATestDefinition qad in qaTestDefinitionList)
                    {
                        session.Save(qad);
                    }
                    foreach(Project pj in projectList)
                    {
                        session.Save(pj);
                    }
                    transaction.Commit();
                }
            }

            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    var projects = session.CreateCriteria(typeof(Project)).List<Project>();
                }
            }
        }
Exemplo n.º 3
0
        public void Init()
        {
            TestDataFactory testDataFac = new TestDataFactory();

            _sessionFactory = SessionFactoryFactory.CreateSessionFactory();

            var productDefinitionList = testDataFac.GenerateTestProductDefinitionList(1);
            var qaTestDefinitionList = new List<QATestDefinition>();

            foreach (ProductDefinition product in productDefinitionList)
            {
                qaTestDefinitionList.AddRange(testDataFac.GenerateTestQATestDefinitionList(product, 1));
            }

            _projectList = testDataFac.PopulateTestData(productDefinitionList, qaTestDefinitionList, 1);
            _firstProject = _projectList[0];
            _firstBuild = _firstProject.Builds[0];
            _firstProduct = _firstBuild.Products[0];
            _firstQATest = _firstProduct.Tests[0];

            using (var session = _sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    foreach (ProductDefinition pd in productDefinitionList)
                    {
                        session.Save(pd);
                    }
                    foreach (QATestDefinition qad in qaTestDefinitionList)
                    {
                        session.Save(qad);
                    }
                    foreach (Project pj in _projectList)
                    {
                        session.Save(pj);
                    }

                    transaction.Commit();
                }
            }
        }