Exemple #1
0
        public void GivenDesiredProductFeature_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            var softwareFeature = new SoftwareFeatureBuilder(this.Session)
                                  .WithVatRegime(new VatRegimes(this.Session).ZeroRated)
                                  .WithName("Tutorial")
                                  .Build();

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

            var builder = new DesiredProductFeatureBuilder(this.Session);

            builder.Build();

            Assert.True(this.Session.Derive(false).HasErrors);

            this.Session.Rollback();

            builder.WithRequired(false);
            builder.Build();

            Assert.True(this.Session.Derive(false).HasErrors);

            this.Session.Rollback();

            builder.WithProductFeature(softwareFeature);
            builder.Build();

            Assert.False(this.Session.Derive(false).HasErrors);
        }
        public void GivenDesiredProductFeature_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            var vatRate21 = new VatRateBuilder(this.DatabaseSession).WithRate(21).Build();
            var softwareFeature = new SoftwareFeatureBuilder(this.DatabaseSession)
                .WithName("Tutorial DVD")
                .WithVatRate(vatRate21)
                .WithLocalisedName(new LocalisedTextBuilder(this.DatabaseSession).WithText("Tutorial").WithLocale(Singleton.Instance(this.DatabaseSession).DefaultLocale).Build())
                .Build();

            this.DatabaseSession.Derive(true);
            this.DatabaseSession.Commit();

            var builder = new DesiredProductFeatureBuilder(this.DatabaseSession);
            builder.Build();

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);

            this.DatabaseSession.Rollback();

            builder.WithRequired(false);
            builder.Build();

            Assert.IsTrue(this.DatabaseSession.Derive().HasErrors);

            this.DatabaseSession.Rollback();

            builder.WithProductFeature(softwareFeature);
            builder.Build();

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