public void TestListenerStateChange() { _epService.ServiceInitialized += _listener.OnEPServiceInitialized; _epService.ServiceDestroyRequested += _listener.OnEPServiceDestroyRequested; _epService.Dispose(); Assert.AreSame(_epService, _listener.AssertOneGetAndResetDestroyedEvents()); _epService.Initialize(); Assert.AreSame(_epService, _listener.AssertOneGetAndResetInitializedEvents()); _epService.RemoveAllServiceStateEventHandlers(); _epService.Initialize(); Assert.IsTrue(_listener.InitializedEvents.IsEmpty()); _epService.ServiceInitialized += _listener.OnEPServiceInitialized; _epService.ServiceDestroyRequested += _listener.OnEPServiceDestroyRequested; _epService.ServiceInitialized += _listenerTwo.OnEPServiceInitialized; _epService.ServiceDestroyRequested += _listenerTwo.OnEPServiceDestroyRequested; _epService.Initialize(); Assert.AreSame(_epService, _listener.AssertOneGetAndResetInitializedEvents()); Assert.AreSame(_epService, _listenerTwo.AssertOneGetAndResetInitializedEvents()); _epService.ServiceInitialized -= _listener.OnEPServiceInitialized; _epService.ServiceDestroyRequested -= _listener.OnEPServiceDestroyRequested; _epService.Initialize(); Assert.AreSame(_epService, _listenerTwo.AssertOneGetAndResetInitializedEvents()); Assert.IsTrue(_listener.InitializedEvents.IsEmpty()); _epService.Dispose(); }
private void RunAssertionListenerStateChange() { var listener = new SupportServiceStateListener(); Configuration configuration = SupportConfigFactory.GetConfiguration(); EPServiceProvider epService = EPServiceProviderManager.GetProvider( SupportContainer.Instance, this.GetType().Name + "__listenerstatechange", configuration); epService.ServiceInitialized += listener.OnEPServiceInitialized; epService.ServiceDestroyRequested += listener.OnEPServiceDestroyRequested; epService.Dispose(); Assert.AreSame(epService, listener.AssertOneGetAndResetDestroyedEvents()); epService.Initialize(); Assert.AreSame(epService, listener.AssertOneGetAndResetInitializedEvents()); epService.RemoveAllServiceStateEventHandlers(); epService.Initialize(); Assert.IsTrue(listener.InitializedEvents.IsEmpty()); epService.ServiceInitialized += listener.OnEPServiceInitialized; epService.ServiceDestroyRequested += listener.OnEPServiceDestroyRequested; var listenerTwo = new SupportServiceStateListener(); epService.ServiceInitialized += listenerTwo.OnEPServiceInitialized; epService.ServiceDestroyRequested += listenerTwo.OnEPServiceDestroyRequested; epService.Initialize(); Assert.AreSame(epService, listener.AssertOneGetAndResetInitializedEvents()); Assert.AreSame(epService, listenerTwo.AssertOneGetAndResetInitializedEvents()); epService.ServiceInitialized -= listener.OnEPServiceInitialized; epService.ServiceDestroyRequested -= listener.OnEPServiceDestroyRequested; epService.Initialize(); Assert.AreSame(epService, listenerTwo.AssertOneGetAndResetInitializedEvents()); Assert.IsTrue(listener.InitializedEvents.IsEmpty()); epService.Dispose(); }