Exemplo n.º 1
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.º 2
0
        public void WillStopOverAt_06()
        {
            // arrange:
            VoyageNumber number   = new VoyageNumber("VYGTEST01");
            ISchedule    schedule = MockRepository.GenerateStrictMock <ISchedule>();

            schedule.Expect(s => s.MovementsCount).Return(3).Repeat.Any();
            UnLocode         loc3 = new UnLocode("ARLCB");
            UnLocode         loc4 = new UnLocode("ARLCC");
            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>();
            UnLocode  outLocation = new UnLocode("LCOUT");

            location.Expect(l => l.UnLocode).Return(outLocation).Repeat.AtLeastOnce();

            // act:
            MovingVoyage state = new MovingVoyage(number, schedule, 2);
            bool         willStopOverAtLocation = state.WillStopOverAt(location);

            // assert:
            Assert.IsFalse(willStopOverAtLocation);
            location.VerifyAllExpectations();
            schedule.VerifyAllExpectations();
            mov3.VerifyAllExpectations();
        }
Exemplo n.º 3
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.º 4
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();
        }
Exemplo n.º 5
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.º 6
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.º 7
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.º 8
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.º 9
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();
        }