Exemple #1
0
        public void GivenSalesRepRelationship_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            var customer = new OrganisationBuilder(this.Session).WithName("customer").WithLocale(new Locales(this.Session).EnglishGreatBritain).Build();

            this.Session.Derive();
            this.Session.Commit();

            var builder      = new SalesRepRelationshipBuilder(this.Session);
            var relationship = builder.Build();

            this.Session.Derive();
            Assert.True(relationship.Strategy.IsDeleted);

            this.Session.Rollback();

            builder.WithCustomer(customer);
            relationship = builder.Build();

            this.Session.Derive();
            Assert.True(relationship.Strategy.IsDeleted);

            this.Session.Rollback();

            builder.WithSalesRepresentative(new PersonBuilder(this.Session).WithLastName("salesrep.").Build());
            builder.Build();

            Assert.False(this.Session.Derive(false).HasErrors);
        }
        public void GivenSalesRepRelationship_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            var customer = new OrganisationBuilder(this.DatabaseSession).WithName("customer").WithLocale(new Locales(this.DatabaseSession).EnglishGreatBritain).Build();
            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();

            var builder = new SalesRepRelationshipBuilder(this.DatabaseSession);
            var relationship = builder.Build();

            this.DatabaseSession.Derive();
            Assert.IsTrue(relationship.Strategy.IsDeleted);

            this.DatabaseSession.Rollback();

            builder.WithCustomer(customer);
            relationship = builder.Build();

            this.DatabaseSession.Derive();
            Assert.IsTrue(relationship.Strategy.IsDeleted);

            this.DatabaseSession.Rollback();

            builder.WithSalesRepresentative(new PersonBuilder(this.DatabaseSession).WithLastName("salesrep.").Build());
            builder.Build();

            Assert.IsFalse(this.DatabaseSession.Derive().HasErrors);
        }