Пример #1
0
		public void Ctor_01()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId id = new TrackingId("START");
			DateTime loadTime = DateTime.Now;
			VoyageNumber voyageNumber = new VoyageNumber("VYG001");
			UnLocode location = new UnLocode("CURLC");
            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(new UnLocode("ENDLC")).Repeat.Any();
            mocks.Add(itinerary);
            IRouteSpecification specification = MockRepository.GenerateStrictMock<IRouteSpecification>();
            specification.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.Any();
            CargoState previousState = MockRepository.GenerateStrictMock<CargoState>(id, specification);
            mocks.Add(previousState);
            previousState = MockRepository.GenerateStrictMock<CargoState>(previousState, itinerary);
            mocks.Add(previousState);
			IVoyage voyage = MockRepository.GenerateStrictMock<IVoyage>();
			voyage.Expect(v => v.Number).Return(voyageNumber).Repeat.AtLeastOnce();
			voyage.Expect(v => v.LastKnownLocation).Return(location).Repeat.AtLeastOnce();
			mocks.Add(voyage);
			
			// act:
			CargoState state = new OnboardCarrierCargo(previousState, voyage, loadTime);
		
			// assert:
			Assert.IsNotNull(state);
			Assert.AreSame(voyageNumber, state.CurrentVoyage);
			Assert.AreEqual(TransportStatus.OnboardCarrier, state.TransportStatus);
			Assert.AreSame(location, state.LastKnownLocation);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}
Пример #2
0
		public void Unload_05()
		{
			// arrange:
            GList mocks = new GList();

			UnLocode code = new UnLocode("START");
			VoyageNumber voyageNumber = new VoyageNumber("ATEST");
			DateTime arrival = DateTime.UtcNow;
			TrackingId id = new TrackingId("CARGO01");
            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.Any();
            mocks.Add(itinerary);
            IRouteSpecification specification = MockRepository.GenerateStrictMock<IRouteSpecification>();
            specification.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.Any();
            mocks.Add(specification);
			IVoyage voyage = MockRepository.GenerateStrictMock<IVoyage>();
			voyage.Expect(v => v.Number).Return(voyageNumber).Repeat.Any();
			voyage.Expect(v => v.LastKnownLocation).Return(code).Repeat.AtLeastOnce();
			voyage.Expect(v => v.NextExpectedLocation).Return(new UnLocode("NEXTL")).Repeat.Any();
			voyage.Expect(v => v.IsMoving).Return(false).Repeat.AtLeastOnce();
			mocks.Add(voyage);
			CargoState previousState = MockRepository.GenerateStrictMock<CargoState>(id, specification);
            mocks.Add(previousState);
            previousState = MockRepository.GenerateStrictMock<CargoState>(previousState, itinerary);
            mocks.Add(previousState);
            previousState.Expect(s => s.LastKnownLocation).Return(code).Repeat.Any();
			OnboardCarrierCargo state = new OnboardCarrierCargo(previousState, voyage, arrival);
		
			// assert:
			Assert.Throws<ArgumentException>(delegate {state.Unload(voyage, arrival - TimeSpan.FromDays(2));});
            foreach (object mock in mocks)
                mock.VerifyAllExpectations();
		}
Пример #3
0
		public void ClearCustoms_01()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId id = new TrackingId("START");
			DateTime loadTime = DateTime.Now;
			VoyageNumber voyageNumber = new VoyageNumber("VYG001");
			UnLocode locCode = new UnLocode("CURLC");
			ILocation location = MockRepository.GenerateStrictMock<ILocation>();
			location.Expect(l => l.UnLocode).Return(locCode).Repeat.Any();
			mocks.Add(location);
            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(new UnLocode("ENDLC")).Repeat.Any();
            mocks.Add(itinerary);
            IRouteSpecification specification = MockRepository.GenerateStrictMock<IRouteSpecification>();
            specification.Expect(s => s.IsSatisfiedBy(itinerary)).Return(true).Repeat.Any();
			mocks.Add(specification);
            CargoState previousState = MockRepository.GenerateStrictMock<CargoState>(id, specification);
            mocks.Add(previousState);
            previousState = MockRepository.GenerateStrictMock<CargoState>(previousState, itinerary);
            mocks.Add(previousState);
			IVoyage voyage = MockRepository.GenerateStrictMock<IVoyage>();
			voyage.Expect(v => v.Number).Return(voyageNumber).Repeat.AtLeastOnce();
			voyage.Expect(v => v.LastKnownLocation).Return(locCode).Repeat.AtLeastOnce();
			mocks.Add(voyage);
			CargoState state = new OnboardCarrierCargo(previousState, voyage, loadTime);
		
			// assert:
			Assert.Throws<InvalidOperationException>(delegate { state.ClearCustoms(location, DateTime.Now + TimeSpan.FromDays(1)); });
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}