public void DepartFrom_02(int index) { // arrange: VoyageNumber number = new VoyageNumber("VYGTEST01"); ISchedule schedule = MockRepository.GenerateStrictMock<ISchedule>(); schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any(); UnLocode initialLocation = new UnLocode("DPLOC"); ICarrierMovement movement = MockRepository.GenerateStrictMock<ICarrierMovement>(); movement.Expect(m => m.DepartureLocation).Return(initialLocation).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.DepartFrom(location);}); schedule.VerifyAllExpectations(); movement.VerifyAllExpectations(); location.VerifyAllExpectations(); }
public void DepartFrom_01(int index) { // arrange: VoyageNumber number = new VoyageNumber("VYGTEST01"); ISchedule schedule = MockRepository.GenerateStrictMock<ISchedule>(); schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any(); UnLocode initialLocation = new UnLocode("DPLOC"); UnLocode destinationLocation = new UnLocode("ARLOC"); ICarrierMovement movement = MockRepository.GenerateStrictMock<ICarrierMovement>(); movement.Expect(m => m.DepartureLocation).Return(initialLocation).Repeat.Any(); movement.Expect(m => m.ArrivalLocation).Return(destinationLocation).Repeat.Any(); schedule.Expect(s => s[index]).Return(movement).Repeat.Any(); ILocation location = MockRepository.GenerateStrictMock<ILocation>(); location.Expect(l => l.UnLocode).Return(initialLocation).Repeat.Any(); // act: MovingVoyage state = new MovingVoyage(number, schedule, index); VoyageState moving = state.DepartFrom(location); // assert: Assert.AreSame(state, moving); schedule.VerifyAllExpectations(); movement.VerifyAllExpectations(); location.VerifyAllExpectations(); }