public void Work_WhenHasCargo_GoesToDestinationAndDropsOff() { _nQueue2.Any().Returns(false); _nQueue1.FirstId().Returns(1); _start.ReceivesType(Arg.Any <Core.Resources.Op.OpTypes>()).Returns(false); _destination.ReceivesType(Arg.Any <Core.Resources.Op.OpTypes>()).Returns(true); _subject.Work(_dayTime); // To Set Destination for (int i = 0; i < 5; i++) { _subject.Work(_dayTime); // To Go There } _subject.Work(_dayTime); // To Arrive Assert.AreEqual(_destination.Name, _subject.CurrentLocation); // Made it to destination Assert.AreEqual(EMPTY_WO_ID, _subject.CargoNumber); // Picked up Cargo -- if any Assert.AreEqual("None", _subject.Destination); // destination is consumed Assert.AreEqual(0, _subject.TransportTime); // Transport is no longer going anywhere _destination.Received().AddToQueue(_workorder); }
public void Work_WhenEmptyButAssignedADestination_GoesThereAndPicksUpCargo() { const int TRANSPORT_TIME = 5; _nQueue1.Any().Returns(false); _nQueue2.FirstId().Returns(1); _destination.ReceivesType(Arg.Any <Core.Resources.Op.OpTypes>()).Returns(false); _start.ReceivesType(Arg.Any <Core.Resources.Op.OpTypes>()).Returns(true); _subject.Work(_dayTime); // To Set Destination for (int i = 0; i < 5; i++) { _subject.Work(_dayTime); // To Go There } _subject.Work(_dayTime); // To Arrive Assert.AreEqual(_destination.Name, _subject.CurrentLocation); // Made it to destination Assert.AreEqual(WORKORDER_ID, _subject.CargoNumber); // Picked up Cargo -- if any Assert.AreEqual(_start.Name, _subject.Destination); // Is now assigned to new destination Assert.AreEqual(TRANSPORT_TIME, _subject.TransportTime); _destination.DidNotReceive().AddToQueue(Arg.Any <IWork>()); _mes.Received().StartTransit(WORKORDER_ID, _subject.CurrentLocation); }