public void Ctor_withValidDelivery_works()
		{
			// arrange:
			IDelivery mDelivery = MockRepository.GenerateStrictMock<IDelivery>();
			DateTime cTime = DateTime.UtcNow;
		
			// act:
			HandlingEventArgs args = new HandlingEventArgs(mDelivery, cTime);
		
			// assert:
			Assert.AreEqual(cTime, args.CompletionDate);
			Assert.AreSame(mDelivery, args.Delivery);
		}
Exemple #2
0
        public void Unload(Voyage.IVoyage voyage, DateTime date)
        {
            // Thread safe, lock free sincronization
            CargoState stateBeforeTransition;
            CargoState previousState = CurrentState;

            do
            {
                stateBeforeTransition = previousState;
                CargoState newValue = stateBeforeTransition.Unload(voyage, date);
                previousState = Interlocked.CompareExchange <CargoState>(ref this.CurrentState, newValue, stateBeforeTransition);
            }while (previousState != stateBeforeTransition);

            if (!previousState.Equals(this.CurrentState))
            {
                HandlingEventArgs args = new HandlingEventArgs(CurrentState, CurrentState.CalculationDate);

                EventHandler <HandlingEventArgs> handler = Unloaded;
                if (null != handler)
                {
                    handler(this, args);
                }
            }
        }