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

            Thread.CurrentPrincipal = new GenericPrincipal(new GenericIdentity("orderProcessor", "Forms"), new string[0]);

            var customer = new PersonBuilder(this.DatabaseSession).WithLastName("customer").Build();

            var shipment = new CustomerShipmentBuilder(this.DatabaseSession)
                .WithShipToParty(customer)
                .WithShipToAddress(shipToAddress)
                .WithShipmentMethod(new ShipmentMethods(this.DatabaseSession).Ground)
                .Build();

            shipment.Cancel();

            this.DatabaseSession.Derive(true);

            var acl = new AccessControlList(shipment, new Users(this.DatabaseSession).GetCurrentUser());
            Assert.IsFalse(acl.CanExecute(CustomerShipments.Meta.Cancel));
        }
Ejemplo n.º 2
0
        public void GivenCustomerShipment_WhenCancelled_ThenCurrentShipmentStatusEqualsCancelled()
        {
            var customer = new PersonBuilder(this.DatabaseSession).WithLastName("customer").Build();
            var mechelen = new CityBuilder(this.DatabaseSession).WithName("Mechelen").Build();
            var shipToAddress = new PostalAddressBuilder(this.DatabaseSession).WithGeographicBoundary(mechelen).WithAddress1("Haverwerf 15").Build();

            var shipment = new CustomerShipmentBuilder(this.DatabaseSession)
                .WithShipToParty(customer)
                .WithShipToAddress(shipToAddress)
                .WithShipmentMethod(new ShipmentMethods(this.DatabaseSession).Ground)
                .Build();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(1, shipment.ShipmentStatuses.Count);
            Assert.AreEqual(new CustomerShipmentObjectStates(this.DatabaseSession).Created, shipment.CurrentShipmentStatus.CustomerShipmentObjectState);

            shipment.Cancel();

            this.DatabaseSession.Derive(true);

            Assert.AreEqual(2, shipment.ShipmentStatuses.Count);
            Assert.AreEqual(new CustomerShipmentObjectStates(this.DatabaseSession).Cancelled, shipment.CurrentShipmentStatus.CustomerShipmentObjectState);
        }