Exemple #1
0
		public void LoadOn_06()
		{
			// arrange:
            List<object> mocks = new List<object>();

            UnLocode code = new UnLocode("FINAL");
            TrackingId id = new TrackingId("CRG01");
			VoyageNumber voyageNumber = new VoyageNumber("ATEST");
            DateTime arrival = DateTime.UtcNow;
			UnLocode voyageLocation = new UnLocode("OTHER");
            IItinerary itinerary = MockRepository.GenerateStrictMock<IItinerary>();
            itinerary.Expect(i => i.Equals(null)).IgnoreArguments().Return(false).Repeat.Any();
            itinerary.Expect(i => i.FinalArrivalDate).Return(DateTime.UtcNow + TimeSpan.FromDays(1)).Repeat.Any();
            itinerary.Expect(i => i.FinalArrivalLocation).Return(code).Repeat.AtLeastOnce();
            mocks.Add(itinerary);
            IRouteSpecification specification = MockRepository.GenerateStrictMock<IRouteSpecification>();
            specification.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.AtLeastOnce();
            mocks.Add(specification);
			IVoyage voyage = MockRepository.GenerateStrictMock<IVoyage>();
			voyage.Expect(v => v.IsMoving).Return(false).Repeat.AtLeastOnce();
			voyage.Expect(v => v.LastKnownLocation).Return(voyageLocation).Repeat.AtLeastOnce();
			voyage.Expect(v => v.Number).Return(voyageNumber).Repeat.AtLeastOnce();
			mocks.Add(voyage);
            CargoState previousState = MockRepository.GenerateStrictMock<CargoState>(id, specification);
            previousState.Expect(s => s.LastKnownLocation).Return(code).Repeat.Any();
            mocks.Add(previousState);
            previousState = MockRepository.GenerateStrictMock<CargoState>(previousState, itinerary);
            mocks.Add(previousState);
            InPortCargo state = new InPortCargo(previousState, voyageLocation, arrival);
			
			// act:
			Assert.Throws<ArgumentException>(delegate { state.LoadOn(voyage, arrival - TimeSpan.FromDays(2)); });
		
			// assert:
			foreach (object mock in mocks)
                mock.VerifyAllExpectations();
		}
Exemple #2
0
		public void LoadOn_02()
		{
			// arrange:
			UnLocode code = new UnLocode("FINAL");
			UnLocode voyageLocation = new UnLocode("OTHER");
			TrackingId id = new TrackingId("CRG01");
			DateTime arrival = DateTime.UtcNow;
			IRouteSpecification specification = MockRepository.GenerateStrictMock<IRouteSpecification>();
			IItinerary itinerary = MockRepository.GenerateStrictMock<IItinerary>();
			itinerary.Expect(i => i.Equals(null)).IgnoreArguments().Return(false).Repeat.Any();
			itinerary.Expect(i => i.FinalArrivalDate).Return(DateTime.UtcNow + TimeSpan.FromDays(1)).Repeat.Any();
			specification.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.AtLeastOnce();
			CargoState previousState = MockRepository.GenerateStrictMock<CargoState>(id, specification);
			previousState.Expect(s => s.LastKnownLocation).Return(code).Repeat.Any();
			previousState = MockRepository.GenerateStrictMock<CargoState>(previousState, itinerary);
			InPortCargo state = new InPortCargo(previousState, voyageLocation, arrival);
		
			// act:
			Assert.Throws<ArgumentNullException>(delegate { state.LoadOn(null, DateTime.UtcNow + TimeSpan.FromDays(2)); });
		
			// assert:
			itinerary.VerifyAllExpectations();
			specification.VerifyAllExpectations();
		}