Exemplo n.º 1
0
		public void Ctor_01(int index)
		{
			// arrange:
			VoyageNumber number = new VoyageNumber("VYGTEST01");
			ISchedule schedule = MockRepository.GenerateStrictMock<ISchedule>();
			schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any();
		
			// act:
			MovingVoyage state = new MovingVoyage(number, schedule, index);
		
			// assert:
			Assert.AreSame(number, state.Number);
			Assert.AreSame(schedule, state.Schedule);
			Assert.IsTrue(state.IsMoving);
		}
Exemplo n.º 2
0
        public override bool Equals(VoyageState other)
        {
            if (object.ReferenceEquals(this, other))
            {
                return(true);
            }
            MovingVoyage voyage = other as MovingVoyage;

            if (null == voyage)
            {
                return(false);
            }
            return(Number.Equals(voyage.Number) &&
                   _movementIndex == voyage._movementIndex &&
                   Schedule.Equals(voyage.Schedule));
        }
Exemplo n.º 3
0
		public void Equals_04()
		{
			// arrange:
			VoyageNumber number = new VoyageNumber("VYGTEST01");
			ISchedule schedule = MockRepository.GenerateStrictMock<ISchedule>();
			schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any();
			schedule.Expect(s => s.Equals(schedule)).Return(true).Repeat.Any();

			// act:
			CompletedVoyage state1 = new CompletedVoyage(number, schedule);
			VoyageState state2 = new MovingVoyage(number, schedule, 2);
			
			// assert:
			Assert.IsFalse(state1.Equals(state2));
			schedule.VerifyAllExpectations();
		}
Exemplo n.º 4
0
		public void LastKnownLocation_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");
			ICarrierMovement movement = MockRepository.GenerateStrictMock<ICarrierMovement>();
			movement.Expect(m => m.DepartureLocation).Return(initialLocation).Repeat.Once();
			schedule.Expect(s => s[index]).Return(movement).Repeat.Once();
		
			// act:
			MovingVoyage state = new MovingVoyage(number, schedule, index);
		
			// assert:
			Assert.AreSame(initialLocation, state.LastKnownLocation);
			movement.VerifyAllExpectations();
			schedule.VerifyAllExpectations();
		}
Exemplo n.º 5
0
		public void WillStopOverAt_08()
		{
			// arrange:
			VoyageNumber number = new VoyageNumber("VYGTEST01");
			ISchedule schedule = MockRepository.GenerateStrictMock<ISchedule>();
			schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any();
			UnLocode loc1 = new UnLocode("DPLOC");
			UnLocode loc2 = new UnLocode("ARLCA");
			UnLocode loc3 = new UnLocode("ARLCB");
			UnLocode loc4 = new UnLocode("ARLCC");
			ICarrierMovement mov1 = MockRepository.GenerateStrictMock<ICarrierMovement>();
			mov1.Expect(m => m.ArrivalLocation).Return(loc2).Repeat.AtLeastOnce();
			schedule.Expect(s => s[0]).Return(mov1).Repeat.Any();
			ICarrierMovement mov2 = MockRepository.GenerateStrictMock<ICarrierMovement>();
			//mov2.Expect(m => m.DepartureLocation).Return(loc2).Repeat.Any();
			mov2.Expect(m => m.ArrivalLocation).Return(loc3).Repeat.AtLeastOnce();
			schedule.Expect(s => s[1]).Return(mov2).Repeat.Any();
			ICarrierMovement mov3 = MockRepository.GenerateStrictMock<ICarrierMovement>();
			//mov3.Expect(m => m.DepartureLocation).Return(loc3).Repeat.Any();
			mov3.Expect(m => m.ArrivalLocation).Return(loc4).Repeat.AtLeastOnce();
			schedule.Expect(s => s[2]).Return(mov3).Repeat.Any();
			ILocation location = MockRepository.GenerateStrictMock<ILocation>();
			location.Expect(l => l.UnLocode).Return(loc1).Repeat.AtLeastOnce();
	
			// act:
			MovingVoyage state = new MovingVoyage(number, schedule, 0);
			bool willStopOverAtLocation = state.WillStopOverAt(location);
		
			// assert:
			Assert.IsFalse(willStopOverAtLocation);
			location.VerifyAllExpectations();
			schedule.VerifyAllExpectations();
			mov1.VerifyAllExpectations();
			mov2.VerifyAllExpectations();
			mov3.VerifyAllExpectations();
		}
Exemplo n.º 6
0
		public void Equals_05(int index)
		{
			// arrange:
			VoyageNumber number = new VoyageNumber("VYGTEST01");
			ISchedule schedule = MockRepository.GenerateStrictMock<ISchedule>();
			schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any();

			// act:
			MovingVoyage state1 = new MovingVoyage(number, schedule, index);
			VoyageState state2 = MockRepository.GeneratePartialMock<VoyageState>(number, schedule);
			
			// assert:
			Assert.IsFalse(state1.Equals(state2));
			schedule.VerifyAllExpectations();
			state2.VerifyAllExpectations();
		}
Exemplo n.º 7
0
		public void Equals_01(int index)
		{
			// arrange:
			VoyageNumber number = new VoyageNumber("VYGTEST01");
			ISchedule schedule = MockRepository.GenerateStrictMock<ISchedule>();
			schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any();
			schedule.Expect(s => s.Equals(schedule)).Return(true).Repeat.Any();

			// act:
			MovingVoyage state1 = new MovingVoyage(number, schedule, index);
			MovingVoyage state2 = new MovingVoyage(number, schedule, index);
			
			// assert:
			Assert.IsFalse(state1.Equals(null));
			Assert.IsTrue(state1.Equals(state1));
			Assert.IsTrue(state1.Equals(state2));
			Assert.IsTrue(state2.Equals(state1));
			Assert.IsTrue(state1.Equals((object)state1));
			Assert.IsTrue(state1.Equals((object)state2));
			Assert.IsTrue(state2.Equals((object)state1));
			schedule.VerifyAllExpectations();
		}
Exemplo n.º 8
0
		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();
		}
Exemplo n.º 9
0
		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();
		} 
Exemplo n.º 10
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();
		}