示例#1
0
		public void Claim_atFinalArrivalLocation_dontCallUnsubscribedHandlersOf_Claimed()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId identifier = new TrackingId("CARGO01");
			VoyageNumber voyageNumber = new VoyageNumber("VYG001");
			DateTime arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
			DateTime recieveDate = DateTime.Now + TimeSpan.FromDays(1);
			UnLocode recUnLocode = new UnLocode("RECLC");
			UnLocode endUnLocode = new UnLocode("FINAL");
			IVoyage voyage = MockRepository.GenerateStrictMock<IVoyage>();
			voyage.Expect(v => v.IsMoving).Return(false).Repeat.AtLeastOnce();
			voyage.Expect(v => v.Number).Return(voyageNumber).Repeat.AtLeastOnce();
			voyage.Expect(v => v.LastKnownLocation).Return(recUnLocode).Repeat.Twice();
			voyage.Expect(v => v.LastKnownLocation).Return(endUnLocode).Repeat.Once();
			mocks.Add(voyage);
			ILocation recLocation = MockRepository.GenerateStrictMock<ILocation>();
			recLocation.Expect(l => l.UnLocode).Return(recUnLocode).Repeat.AtLeastOnce();
			mocks.Add(recLocation);
			ILocation clmLocation = MockRepository.GenerateStrictMock<ILocation>();
			clmLocation.Expect(l => l.UnLocode).Return(endUnLocode).Repeat.AtLeastOnce();
			mocks.Add(clmLocation);
			IItinerary itinerary = MockRepository.GenerateStrictMock<IItinerary>();
			itinerary.Expect(i => i.Equals(null)).Return(false).Repeat.Any();
			itinerary.Expect(i => i.FinalArrivalDate).Return(arrivalDate).Repeat.Any();
			itinerary.Expect(i => i.FinalArrivalLocation).Return(endUnLocode).Repeat.Any();
			itinerary.Expect(i => i.InitialDepartureLocation).Return(recUnLocode).Repeat.Any();
			mocks.Add(itinerary);
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			route.Expect(r => r.IsSatisfiedBy(itinerary)).Return(true).Repeat.AtLeastOnce();
			mocks.Add(route);
			HandlingEventArgs eventArguments = null;
			ICargo eventSender = null;
		
			// act:
			EventHandler<HandlingEventArgs> handler = delegate(object sender, HandlingEventArgs e) {
				eventArguments = e;
				eventSender = sender as ICargo;
			};
			TCargo underTest = new TCargo(identifier, route);
			underTest.AssignToRoute(itinerary);
			underTest.Recieve(recLocation, recieveDate);
			underTest.LoadOn(voyage, recieveDate + TimeSpan.FromDays(1));
			underTest.Unload(voyage, recieveDate + TimeSpan.FromDays(10));
			underTest.Claimed += handler;
			underTest.Claimed -= handler;
			underTest.Claim(clmLocation, recieveDate + TimeSpan.FromDays(11));
		
			// assert:
			Assert.IsNull(eventArguments);
			Assert.IsNull(eventSender);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}
示例#2
0
		public void Claim_atFinalArrivalLocation_setTheTransportStatusToClaimed()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId identifier = new TrackingId("CARGO01");
			VoyageNumber voyageNumber = new VoyageNumber("VYG001");
			DateTime arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
			DateTime recieveDate = DateTime.Now + TimeSpan.FromDays(1);
			UnLocode recUnLocode = new UnLocode("RECLC");
			UnLocode endUnLocode = new UnLocode("FINAL");
			IVoyage voyage = MockRepository.GenerateStrictMock<IVoyage>();
			voyage.Expect(v => v.IsMoving).Return(false).Repeat.AtLeastOnce();
			voyage.Expect(v => v.Number).Return(voyageNumber).Repeat.AtLeastOnce();
			voyage.Expect(v => v.LastKnownLocation).Return(recUnLocode).Repeat.Twice();
			voyage.Expect(v => v.LastKnownLocation).Return(endUnLocode).Repeat.Once();
			mocks.Add(voyage);
			ILocation recLocation = MockRepository.GenerateStrictMock<ILocation>();
			recLocation.Expect(l => l.UnLocode).Return(recUnLocode).Repeat.AtLeastOnce();
			mocks.Add(recLocation);
			ILocation clmLocation = MockRepository.GenerateStrictMock<ILocation>();
			clmLocation.Expect(l => l.UnLocode).Return(endUnLocode).Repeat.AtLeastOnce();
			mocks.Add(clmLocation);
			IItinerary itinerary = MockRepository.GenerateStrictMock<IItinerary>();
			itinerary.Expect(i => i.Equals(null)).Return(false).Repeat.Any();
			itinerary.Expect(i => i.FinalArrivalDate).Return(arrivalDate).Repeat.Any();
			itinerary.Expect(i => i.FinalArrivalLocation).Return(endUnLocode).Repeat.Any();
			itinerary.Expect(i => i.InitialDepartureLocation).Return(recUnLocode).Repeat.Any();
			mocks.Add(itinerary);
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			route.Expect(r => r.IsSatisfiedBy(itinerary)).Return(true).Repeat.AtLeastOnce();
			mocks.Add(route);
		
			// act:
			TCargo underTest = new TCargo(identifier, route);
			underTest.AssignToRoute(itinerary);
			underTest.Recieve(recLocation, recieveDate);
			underTest.LoadOn(voyage, recieveDate + TimeSpan.FromDays(1));
			underTest.Unload(voyage, recieveDate + TimeSpan.FromDays(10));
			underTest.Claim(clmLocation, recieveDate + TimeSpan.FromDays(11));

		
			// assert:
			Assert.AreEqual(TransportStatus.Claimed, underTest.Delivery.TransportStatus);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}