Пример #1
0
        public void ReceiveShipmentInCargoBay(string shipmentName, InventoryShipment shipment)
        {
            ThrowExceptionIfFactoryIsNotOpen();

            if (_aggregateState.ListOfEmployeeNames.Count == 0)
                throw DomainError.Named("unknown-employee", ":> There has to be somebody at factory in order to accept shipment");
            
            if (shipment.Cargo.Length == 0)
                throw DomainError.Named("empty-InventoryShipments", ":> Empty InventoryShipments are not accepted!");

            if (_aggregateState.ShipmentsWaitingToBeUnpacked.Count >= 2)
                throw DomainError.Named("more-than-two-InventoryShipments", ":> More than two InventoryShipments can't fit into this cargo bay :(");

            DoRealWork("opening cargo bay doors");

            RecordAndRealizeThat(new ShipmentReceivedInCargoBay(_aggregateState.Id, shipment));

            // TODO:  This is a Test from before that I need to add back

            //var totalCountOfParts = shipment.Cargo.Sum(p => p.Quantity);
            //if (totalCountOfParts > 10)
            //{
            //    RecordAndRealizeThat(new CurseWordUttered(_aggregateState.Id, "Boltov tebe v korobky peredach",
            //                               "awe in the face of the amount of shipment delivered"));
            //}
        }
        public void shipment_already_unloaded()
        {
            var shipment = new InventoryShipment("ship-1", new[] {new CarPart("chassis", 1),});

            Given(new FactoryOpened(Id),
                  new EmployeeAssignedToFactory(Id, "fry"),
                  new ShipmentTransferredToCargoBay(Id, shipment),
                  new UnloadedFromCargoBay(Id, "fry", new[] { shipment, }));
            When(new UnloadShipmentFromCargoBay(Id, "fry"));
            Expect("empty-InventoryShipments");
        }
Пример #3
0
        public void TransferShipmentToCargoBay(string shipmentName, InventoryShipment shipment)
        {
            ThrowExceptionIfNotOpenFactory();
            //Print("?> Command: transfer shipment to cargo bay");
            if (_state.ListOfEmployeeNames.Count == 0)
                throw DomainError.Named("unknown-employee", ":> There has to be somebody at factory in order to accept shipment");
            
            if (shipment.Cargo.Length == 0)
                throw DomainError.Named("empty-InventoryShipments", ":> Empty InventoryShipments are not accepted!");

            if (_state.ShipmentsWaitingToBeUnloaded.Count >= 2)
                throw DomainError.Named("more-than-two-InventoryShipments", ":> More than two InventoryShipments can't fit into this cargo bay :(");

            DoRealWork("opening cargo bay doors");
            Apply(new ShipmentTransferredToCargoBay(_state.Id, shipment));

            var totalCountOfParts = shipment.Cargo.Sum(p => p.Quantity);
            if (totalCountOfParts > 10)
            {
                Apply(new CurseWordUttered(_state.Id, "Boltov tebe v korobky peredach",
                                           "awe in the face of the amount of shipment delivered"));
            }
        }
Пример #4
0
 ShipmentUnpackedInCargoBay()
 {
     InventoryShipments = new InventoryShipment[0];
 }
Пример #5
0
 public ShipmentUnpackedInCargoBay(FactoryId id, string employeeName, InventoryShipment[] inventoryShipments)
 {
     Id = id;
     EmployeeName = employeeName;
     InventoryShipments = inventoryShipments;
 }
Пример #6
0
 public ShipmentReceivedInCargoBay(FactoryId id, InventoryShipment shipment)
 {
     Id = id;
     Shipment = shipment;
 }