Ejemplo n.º 1
0
        public void GivenCustomerShipment_WhenDeriving_ThenRequiredRelationsMustExist()
        {
            var mechelen = new CityBuilder(this.DatabaseSession).WithName("Mechelen").Build();
            var shipToAddress = new PostalAddressBuilder(this.DatabaseSession).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build();
            var customer = new OrganisationBuilder(this.DatabaseSession).WithName("customer").Build();

            this.DatabaseSession.Commit();

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

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

            this.DatabaseSession.Rollback();

            builder.WithShipToParty(customer);
            builder.Build();

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

            this.DatabaseSession.Rollback();

            builder.WithShipmentMethod(new ShipmentMethods(this.DatabaseSession).Ground);
            builder.Build();

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

            this.DatabaseSession.Rollback();

            builder.WithCarrier(new Carriers(this.DatabaseSession).Fedex);
            builder.Build();

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

            this.DatabaseSession.Rollback();

            builder.WithShipToAddress(shipToAddress);
            builder.Build();

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