예제 #1
0
        protected Company CreateFailedCompany(CompanyCreationType companyCreationType)
        {
            Company company = CreateCompany(companyCreationType);

            // ReSharper disable once ObjectCreationAsStatement
            new FailedCompany
            {
                FailingDate = Now,
                Company     = company
            };

            Company savedCompany;

            using (ITransaction trans = Session.BeginTransaction(IsolationLevel.ReadCommitted))
            {
                savedCompany = Repository.Merge(company);
                trans.Commit();
            }

            Session.Clear();

            Assert.AreNotSame(company, savedCompany);
            Assert.IsNotNull(savedCompany.FailedCompany);
            Assert.IsTrue(savedCompany.IsFailed);

            return(savedCompany);
        }
예제 #2
0
        protected Company CreateCompany(CompanyCreationType companyCreationType)
        {
            Company company =
                new Company
            {
                Name = "Peopleware NV"
            };

            if (companyCreationType == CompanyCreationType.WITH_2_CHILDREN)
            {
                // ReSharper disable once ObjectCreationAsStatement
                new CompanyIdentification
                {
                    Identification = "1",
                    Company        = company
                };

                // ReSharper disable once ObjectCreationAsStatement
                new CompanyIdentification
                {
                    Identification = "2",
                    Company        = company
                };
            }

            Company savedCompany;

            using (ITransaction trans = Session.BeginTransaction(IsolationLevel.ReadCommitted))
            {
                savedCompany = Repository.Merge(company);
                trans.Commit();
            }

            Session.Clear();

            Assert.AreNotSame(company, savedCompany);
            Assert.AreEqual(1, savedCompany.PersistenceVersion);
            Assert.AreEqual(companyCreationType == CompanyCreationType.NO_CHILDREN ? 0 : 2, savedCompany.Identifications.Count);

            return(savedCompany);
        }
        protected Company CreateCompany(CompanyCreationType companyCreationType)
        {
            Company company =
                new Company
                {
                    Name = "Peopleware NV"
                };

            if (companyCreationType == CompanyCreationType.WITH_2_CHILDREN)
            {
                // ReSharper disable once ObjectCreationAsStatement
                new CompanyIdentification
                {
                    Identification = "1",
                    Company = company
                };

                // ReSharper disable once ObjectCreationAsStatement
                new CompanyIdentification
                {
                    Identification = "2",
                    Company = company
                };
            }

            Company savedCompany;
            using (ITransaction trans = Session.BeginTransaction(IsolationLevel.ReadCommitted))
            {
                savedCompany = Repository.Merge(company);
                trans.Commit();
            }

            Session.Clear();

            Assert.AreNotSame(company, savedCompany);
            Assert.AreEqual(1, savedCompany.PersistenceVersion);
            Assert.AreEqual(companyCreationType == CompanyCreationType.NO_CHILDREN ? 0 : 2, savedCompany.Identifications.Count);

            return savedCompany;
        }
        protected Company CreateFailedCompany(CompanyCreationType companyCreationType)
        {
            Company company = CreateCompany(companyCreationType);

            // ReSharper disable once ObjectCreationAsStatement
            new FailedCompany
            {
                FailingDate = Now,
                Company = company
            };

            Company savedCompany;
            using (ITransaction trans = Session.BeginTransaction(IsolationLevel.ReadCommitted))
            {
                savedCompany = Repository.Merge(company);
                trans.Commit();
            }

            Session.Clear();

            Assert.AreNotSame(company, savedCompany);
            Assert.IsNotNull(savedCompany.FailedCompany);
            Assert.IsTrue(savedCompany.IsFailed);

            return savedCompany;
        }