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(); }