示例#1
0
		public void Ctor_withValidArgs_isNotRecieved()
		{
			// arrange:
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
		
			// act:
			TCargo tested = new TCargo(identifier, route);
		
			// assert:
			Assert.AreEqual(TransportStatus.NotReceived, tested.Delivery.TransportStatus);
		}
示例#2
0
		public void Ctor_withValidArgs_works()
		{
			// arrange:
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
		
			// act:
			TCargo tested = new TCargo(identifier, route);
		
			// assert:
			Assert.AreSame(identifier, tested.TrackingId);
			Assert.AreSame(route, tested.RouteSpecification);
			Assert.IsNotNull(tested.Delivery);
		}
示例#3
0
		public void SpecifyNewRoute_withAnotherSpecification_keepTheRoutingStatusUnchanged()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			IRouteSpecification route2 = MockRepository.GenerateStrictMock<IRouteSpecification>();
			route.Expect(r => r.Equals(route2)).Return(false).Repeat.AtLeastOnce();
			mocks.Add(route);
			mocks.Add(route2);
		
			// act:
			TCargo underTest = new TCargo(identifier, route);
			underTest.SpecifyNewRoute(route2);
		
			// assert:
			Assert.AreEqual(RoutingStatus.NotRouted, underTest.Delivery.RoutingStatus);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}
示例#4
0
		public void SpecifyNewRoute_withAnotherSpecification_fireNewRouteSpecified()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			IRouteSpecification route2 = MockRepository.GenerateStrictMock<IRouteSpecification>();
			route.Expect(r => r.Equals(route2)).Return(false).Repeat.AtLeastOnce();
			mocks.Add(route);
			mocks.Add(route2);
			ChangeEventArgs<IRouteSpecification> eventArguments = null;
			ICargo eventSender = null;
		
			// act:
			TCargo underTest = new TCargo(identifier, route);
			underTest.NewRouteSpecified += delegate(object sender, ChangeEventArgs<IRouteSpecification> e) {
				eventArguments = e;
				eventSender = sender as ICargo;
			};
			underTest.SpecifyNewRoute(route2);
		
			// assert:
			Assert.AreSame(route2, eventArguments.NewValue);
			Assert.AreSame(route, eventArguments.OldValue);
			Assert.AreSame(eventSender, underTest);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}
示例#5
0
		public void SpecifyNewRoute_withNullSpecification_throwsArgumentNullException()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			mocks.Add(route);
		
			// act:
			TCargo underTest = new TCargo(identifier, route);
			Assert.Throws<ArgumentNullException>( delegate { underTest.SpecifyNewRoute(null); });
		
			// assert:
			Assert.AreEqual(RoutingStatus.NotRouted, underTest.Delivery.RoutingStatus);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}
示例#6
0
		public void ClearCustoms_atCurrentLocation_dontCallUnsubscribedHandlersOf_CustomsCleared()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId identifier = new TrackingId("CARGO01");
			DateTime arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
			DateTime recieveDate = DateTime.Now + TimeSpan.FromDays(1);
			UnLocode recUnLocode = new UnLocode("RECLC");
			ILocation recLocation = MockRepository.GenerateStrictMock<ILocation>();
			recLocation.Expect(l => l.UnLocode).Return(recUnLocode).Repeat.AtLeastOnce();
			mocks.Add(recLocation);
			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.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.CustomsCleared += handler;
			underTest.CustomsCleared -= handler;
			underTest.ClearCustoms(recLocation, recieveDate + TimeSpan.FromHours(6));
		
			// assert:
			Assert.AreEqual(RoutingStatus.Routed, underTest.Delivery.RoutingStatus);
			Assert.AreEqual(TransportStatus.InPort, underTest.Delivery.TransportStatus);
			Assert.AreSame(recUnLocode, underTest.Delivery.LastKnownLocation);
			Assert.IsNull(eventArguments);
			Assert.IsNull(eventSender);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}
示例#7
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();
		}
示例#8
0
		public void Ctor_withValidArgs_isNotUnloadedAtDestination()
		{
			// arrange:
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
		
			// act:
			TCargo tested = new TCargo(identifier, route);
		
			// assert:
			Assert.IsFalse(tested.Delivery.IsUnloadedAtDestination);
		}		
示例#9
0
		public void AssignToRoute_withNullItinerary_throwsArgumentNullException()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			mocks.Add(route);
		
			// act:
			TCargo underTest = new TCargo(identifier, route);
			Assert.Throws<ArgumentNullException>( delegate { underTest.AssignToRoute(null); });
		
			// assert:
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}
示例#10
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();
		}
示例#11
0
		public void Unload_fromVoyage_resetCurrentVoyage()
		{
			// arrange:
			GList mocks = new GList();
			VoyageNumber voyageNumber = new VoyageNumber("VYG001");
			TrackingId identifier = new TrackingId("CARGO01");
			DateTime arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
			DateTime recDate = DateTime.Now + TimeSpan.FromHours(1);
			DateTime loadDate = DateTime.Now + TimeSpan.FromDays(1);
			UnLocode initialLocation = new UnLocode("INITL");
			UnLocode finalLocation = new UnLocode("FINAL");
			ILocation recLocation = MockRepository.GenerateStrictMock<ILocation>();
			recLocation.Expect(l => l.UnLocode).Return(initialLocation).Repeat.AtLeastOnce();
			mocks.Add(recLocation);
			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(initialLocation).Repeat.Twice();
			voyage.Expect(v => v.LastKnownLocation).Return(finalLocation).Repeat.Once();
			mocks.Add(voyage);
			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(finalLocation).Repeat.Any();
			itinerary.Expect(i => i.InitialDepartureLocation).Return(initialLocation).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, recDate);
			underTest.LoadOn(voyage, loadDate);
			underTest.Unload(voyage, loadDate + TimeSpan.FromDays(10));
		
			// assert:
			Assert.IsNull(underTest.Delivery.CurrentVoyage);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}
示例#12
0
		public void LoadOn_Voyage_fireLoaded()
		{
			// arrange:
			GList mocks = new GList();
			VoyageNumber voyageNumber = new VoyageNumber("VYG001");
			TrackingId identifier = new TrackingId("CARGO01");
			DateTime arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
			DateTime recDate = DateTime.Now + TimeSpan.FromHours(1);
			DateTime loadDate = DateTime.Now + TimeSpan.FromDays(1);
			UnLocode initialLocation = new UnLocode("INITL");
			ILocation recLocation = MockRepository.GenerateStrictMock<ILocation>();
			recLocation.Expect(l => l.UnLocode).Return(initialLocation).Repeat.AtLeastOnce();
			mocks.Add(recLocation);
			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(initialLocation).Repeat.AtLeastOnce();
			mocks.Add(voyage);
			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(new UnLocode("FINAL")).Repeat.Any();
			itinerary.Expect(i => i.InitialDepartureLocation).Return(initialLocation).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, recDate);
			underTest.Loaded += handler;
			underTest.LoadOn(voyage, loadDate);
		
			// assert:
			Assert.IsNotNull(eventArguments);
			Assert.AreSame(underTest.Delivery, eventArguments.Delivery);
			Assert.AreSame(eventSender, underTest);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}
示例#13
0
		public void Ctor_withValidArgs_isWithoutItinerary()
		{
			// arrange:
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
		
			// act:
			TCargo tested = new TCargo(identifier, route);
		
			// assert:
			Assert.IsNull(tested.Itinerary);
		}	
示例#14
0
		public void SpecifyNewRoute_withASpecificationNotMatchingTheItinerary_setTheRoutingStatusMisrouted()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId identifier = new TrackingId("CARGO01");
			DateTime arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
			IItinerary itinerary = MockRepository.GenerateStrictMock<IItinerary>();
			itinerary.Expect(i => i.Equals(null)).Return(false).Repeat.Any();
			itinerary.Expect(i => i.FinalArrivalDate).Return(arrivalDate).Repeat.Any();
			mocks.Add(itinerary);
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			IRouteSpecification route2 = MockRepository.GenerateStrictMock<IRouteSpecification>();
			route.Expect(r => r.Equals(route2)).Return(false).Repeat.AtLeastOnce();
			route.Expect(r => r.IsSatisfiedBy(itinerary)).Return(true).Repeat.AtLeastOnce();
			route2.Expect(r => r.IsSatisfiedBy(itinerary)).Return(false).Repeat.AtLeastOnce();
			mocks.Add(route);
			mocks.Add(route2);
		
			// act:
			TCargo underTest = new TCargo(identifier, route);
			underTest.AssignToRoute(itinerary);
			underTest.SpecifyNewRoute(route2);
		
			// assert:
			Assert.AreEqual(RoutingStatus.Misrouted, underTest.Delivery.RoutingStatus);
			Assert.AreSame(route2, underTest.RouteSpecification);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}
示例#15
0
		public void AssignToRoute_withAnotherItinerary_fireItineraryChanged()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId identifier = new TrackingId("CARGO01");
			DateTime arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
			IItinerary itinerary = MockRepository.GenerateStrictMock<IItinerary>();
			itinerary.Expect(i => i.Equals(null)).Return(false).Repeat.Any();
			itinerary.Expect(i => i.FinalArrivalDate).Return(arrivalDate).Repeat.Any();
			mocks.Add(itinerary);
			IItinerary itinerary2 = MockRepository.GenerateStrictMock<IItinerary>();
			itinerary2.Expect(i => i.Equals((IItinerary)itinerary)).Return(false).Repeat.Any();
			itinerary2.Expect(i => i.FinalArrivalDate).Return(arrivalDate).Repeat.Any();
			mocks.Add(itinerary2);
			itinerary.Expect(i => i.Equals((IItinerary)itinerary2)).Return(false).Repeat.Any();
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			route.Expect(r => r.IsSatisfiedBy(itinerary)).Return(true).Repeat.AtLeastOnce();
			route.Expect(r => r.IsSatisfiedBy(itinerary2)).Return(true).Repeat.AtLeastOnce();
			route.Expect(s => s.Equals(route)).Return(true).Repeat.Any();
			mocks.Add(route);
			ChangeEventArgs<IItinerary> eventArguments = null;
			ICargo eventSender = null;
		
			// act:
			TCargo underTest = new TCargo(identifier, route);
			underTest.AssignToRoute(itinerary);
			Assert.AreSame(itinerary, underTest.Itinerary);
			underTest.ItineraryChanged += delegate(object sender, ChangeEventArgs<IItinerary> e) {
				eventArguments = e;
				eventSender = sender as ICargo;
			};
			underTest.AssignToRoute(itinerary2);
		
			// assert:
			Assert.AreSame(itinerary2, eventArguments.NewValue);
			Assert.AreSame(itinerary, eventArguments.OldValue);
			Assert.AreSame(eventSender, underTest);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}		
示例#16
0
		public void Recieve_atInitialLocation_setTransportStatusInPort()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId identifier = new TrackingId("CARGO01");
			DateTime arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
			DateTime recieveDate = DateTime.Now + TimeSpan.FromDays(1);
			UnLocode recUnLocode = new UnLocode("RECLC");
			ILocation recLocation = MockRepository.GenerateStrictMock<ILocation>();
			recLocation.Expect(l => l.UnLocode).Return(recUnLocode).Repeat.AtLeastOnce();
			mocks.Add(recLocation);
			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.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);
		
			// assert:
			Assert.AreEqual(RoutingStatus.Routed, underTest.Delivery.RoutingStatus);
			Assert.AreEqual(TransportStatus.InPort, underTest.Delivery.TransportStatus);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}
示例#17
0
		public void AssignToRoute_withAnotherItinerary_checkTheRouteSpecification()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId identifier = new TrackingId("CARGO01");
			DateTime arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
			IItinerary itinerary = MockRepository.GenerateStrictMock<IItinerary>();
			itinerary.Expect(i => i.Equals((IItinerary)null)).Return(false).Repeat.Any();
			itinerary.Expect(i => i.FinalArrivalDate).Return(arrivalDate).Repeat.Any();
			mocks.Add(itinerary);
			IItinerary itinerary2 = MockRepository.GenerateStrictMock<IItinerary>();
			itinerary2.Expect(i => i.Equals((IItinerary)itinerary)).Return(false).Repeat.Any();
			itinerary2.Expect(i => i.FinalArrivalDate).Return(arrivalDate).Repeat.Any();
			mocks.Add(itinerary2);
			itinerary.Expect(i => i.Equals((IItinerary)itinerary2)).Return(false).Repeat.Any();
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
			route.Expect(r => r.IsSatisfiedBy(itinerary)).Return(true).Repeat.AtLeastOnce();
			route.Expect(r => r.IsSatisfiedBy(itinerary2)).Return(true).Repeat.AtLeastOnce();
			route.Expect(s => s.Equals(route)).Return(true).Repeat.Any();
			mocks.Add(route);
		
			// act:
			TCargo underTest = new TCargo(identifier, route);
			underTest.AssignToRoute(itinerary);
			Assert.AreSame(itinerary, underTest.Itinerary);
			underTest.AssignToRoute(itinerary2);
		
			// assert:
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}		
示例#18
0
		public void Recieve_atInitialLocation_fireRecieved()
		{
			// arrange:
			GList mocks = new GList();
			TrackingId identifier = new TrackingId("CARGO01");
			DateTime arrivalDate = DateTime.Now + TimeSpan.FromDays(30);
			DateTime recieveDate = DateTime.Now + TimeSpan.FromDays(1);
			UnLocode recUnLocode = new UnLocode("RECLC");
			ILocation recLocation = MockRepository.GenerateStrictMock<ILocation>();
			recLocation.Expect(l => l.UnLocode).Return(recUnLocode).Repeat.AtLeastOnce();
			mocks.Add(recLocation);
			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.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:
			TCargo underTest = new TCargo(identifier, route);
			underTest.AssignToRoute(itinerary);
			underTest.Recieved += delegate(object sender, HandlingEventArgs e) {
				eventArguments = e;
				eventSender = sender as ICargo;
			};
			underTest.Recieve(recLocation, recieveDate);
		
			// assert:
			Assert.IsNotNull(eventArguments);
			Assert.AreSame(underTest.Delivery.LastKnownLocation, eventArguments.Delivery.LastKnownLocation);
			Assert.AreSame(eventSender, underTest);
			foreach(object mock in mocks)
				mock.VerifyAllExpectations();
		}
示例#19
0
		public void Ctor_withValidArgs_isNotDelivered()
		{
			// arrange:
			TrackingId identifier = new TrackingId("CARGO01");
			IRouteSpecification route = MockRepository.GenerateStrictMock<IRouteSpecification>();
		
			// act:
			TCargo tested = new TCargo(identifier, route);
		
			// assert:
			Assert.IsNull(tested.Delivery.CurrentVoyage);
			Assert.IsNull(tested.Delivery.EstimatedTimeOfArrival);
			Assert.IsNull(tested.Delivery.LastKnownLocation);
		}