示例#1
0
        public void GivenOrderItem_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            this.InstantiateObjects(this.Session);

            var buyer    = new OrganisationBuilder(this.Session).WithName("buyer").Build();
            var mechelen = new CityBuilder(this.Session).WithName("Mechelen").Build();
            var shipToContactMechanism = new PostalAddressBuilder(this.Session).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build();
            var partyContactMechanism  = new PartyContactMechanismBuilder(this.Session).WithContactMechanism(shipToContactMechanism).Build();
            var part = new NonUnifiedPartBuilder(this.Session)
                       .WithProductIdentification(new PartNumberBuilder(this.Session)
                                                  .WithIdentification("1")
                                                  .WithProductIdentificationType(new ProductIdentificationTypes(this.Session).Part).Build())
                       .Build();

            buyer.AddPartyContactMechanism(partyContactMechanism);

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

            var builder = new PurchaseOrderItemBuilder(this.Session);

            order.AddPurchaseOrderItem(builder.Build());

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

            this.Session.Rollback();

            builder.WithPart(part);
            order.AddPurchaseOrderItem(builder.Build());

            Assert.False(this.Session.Derive(false).HasErrors);
        }
示例#2
0
        public void GivenOrderItem_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            this.InstantiateObjects(this.DatabaseSession);

            var buyer = new OrganisationBuilder(this.DatabaseSession).WithName("buyer").Build();
            var mechelen = new CityBuilder(this.DatabaseSession).WithName("Mechelen").Build();
            var shipToContactMechanism = new PostalAddressBuilder(this.DatabaseSession).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build();
            var partyContactMechanism = new PartyContactMechanismBuilder(this.DatabaseSession).WithContactMechanism(shipToContactMechanism).Build();
            var part = new RawMaterialBuilder(this.DatabaseSession).WithName("raw stuff").Build();
            buyer.AddPartyContactMechanism(partyContactMechanism);

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

            var builder = new PurchaseOrderItemBuilder(this.DatabaseSession);
            order.AddPurchaseOrderItem(builder.Build());

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

            this.DatabaseSession.Rollback();

            builder.WithPart(part);
            order.AddPurchaseOrderItem(builder.Build());

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

            builder.WithProduct(new GoodBuilder(this.DatabaseSession).Build());
            var orderItem = builder.Build();
            order.AddPurchaseOrderItem(orderItem);

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

            orderItem.RemovePart();

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