コード例 #1
0
        public void BuildIsStoredToDatabaseOnSave()
        {
            TestDataFactory tdf = new TestDataFactory();
            ISessionFactory sessionFactory = SessionFactoryFactory.CreateSessionFactory();

            var masterProductItem = tdf.GenerateTestProductDefinitionList(1)[0];
            var testProject = new Project(Guid.NewGuid(), "StandAlone Project 2","This is the project for the standalone build test.",DateTime.Now);
            var testBuild = new Build(Guid.NewGuid(), testProject.Id, "StandAlone Build 1", "This is the build that has no products or tests.");

            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    session.Save(masterProductItem);
                    session.Save(testProject);
                    session.Save(testBuild);

                    transaction.Commit();
                }
            }
        }
コード例 #2
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);
        }
コード例 #3
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>();
                }
            }
        }
コード例 #4
0
        public void QATestIsStoredToDatabaseOnSave()
        {
            TestDataFactory tdf = new TestDataFactory();
            ISessionFactory sessionFactory = SessionFactoryFactory.CreateSessionFactory();

            var masterProductItem = tdf.GenerateTestProductDefinitionList(1)[0];
            var masterQATestItem = tdf.GenerateTestQATestDefinitionList(masterProductItem, 1)[0];

            var testProject = new Project(Guid.NewGuid(), "StandAlone Project 4", "This is the project for the standalone QATest test.", DateTime.Now);
            var testBuild = new Build(Guid.NewGuid(), testProject.Id, "StandAlone Build 3", "This is the build for the standalone QAtest test.");
            var testProduct = new Product(Guid.NewGuid(), masterProductItem.Id, testBuild.Id, "StandAlone Test Product 2", "This is the Product for the standalone QATest test.");
            var testQATest = new QATest(Guid.NewGuid(), masterQATestItem.Id, testProduct.Id, "StandAlone Test QATest 1", "This is the QA test for testing the QA test save.",0,"");

            using (var session = sessionFactory.OpenSession())
            {
                using (var transaction = session.BeginTransaction())
                {
                    session.Save(masterProductItem);
                    session.Save(masterQATestItem);
                    session.Save(testProject);
                    session.Save(testBuild);
                    session.Save(testProduct);
                    session.Save(testQATest);

                    transaction.Commit();
                }
            }
        }
コード例 #5
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();
                }
            }
        }