Beispiel #1
0
		public void StopOverAt_Destination_01(int index, int movementsCount)
		{
			// arrange:
			VoyageNumber number = new VoyageNumber("VYGTEST01");
			ISchedule schedule = MockRepository.GenerateStrictMock<ISchedule>();
			schedule.Expect(s => s.MovementsCount).Return(movementsCount).Repeat.Any();
			UnLocode arrivalLocation = new UnLocode("ARLOC");
			ICarrierMovement movement1 = MockRepository.GenerateStrictMock<ICarrierMovement>();
			movement1.Expect(m => m.ArrivalLocation).Return(arrivalLocation).Repeat.Times(3);
			schedule.Expect(s => s[index]).Return(movement1).Repeat.Times(3);
			ILocation location = MockRepository.GenerateStrictMock<ILocation>();
			location.Expect(l => l.UnLocode).Return(arrivalLocation).Repeat.Any();

			
			// act:
			MovingVoyage state = new MovingVoyage(number, schedule, index);
			VoyageState stopped = state.StopOverAt(location);
		
			// assert:
			Assert.IsInstanceOf<CompletedVoyage>(stopped);
			Assert.AreSame(state.NextExpectedLocation, stopped.LastKnownLocation);
			Assert.IsFalse(stopped.IsMoving);
			schedule.VerifyAllExpectations();
			movement1.VerifyAllExpectations();
			location.VerifyAllExpectations();
		}
Beispiel #2
0
		public void StopOverAt_02(int index)
		{
			// arrange:
			VoyageNumber number = new VoyageNumber("VYGTEST01");
			ISchedule schedule = MockRepository.GenerateStrictMock<ISchedule>();
			schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any();
			UnLocode arrivalLocation = new UnLocode("ARLOC");
			ICarrierMovement movement = MockRepository.GenerateStrictMock<ICarrierMovement>();
			movement.Expect(m => m.ArrivalLocation).Return(arrivalLocation).Repeat.Any();
			schedule.Expect(s => s[index]).Return(movement).Repeat.Any();
			ILocation location = MockRepository.GenerateStrictMock<ILocation>();
			location.Expect(l => l.UnLocode).Return(new UnLocode("ANTHR")).Repeat.Any();
			
			// act:
			MovingVoyage state = new MovingVoyage(number, schedule, index);

			// assert:
			Assert.Throws<ArgumentException>(delegate {state.StopOverAt(location);});
			schedule.VerifyAllExpectations();
			movement.VerifyAllExpectations();
			location.VerifyAllExpectations();
		}