/*============================================================================*/ /* Private Functions */ /*============================================================================*/ private void Destroy() { object[] configuratorsByChannelKeys = new object[_configuratorsByChannel.Keys.Count]; _configuratorsByChannel.Keys.CopyTo(configuratorsByChannelKeys, 0); foreach (object channelId in configuratorsByChannelKeys) { ModuleConnectionConfigurator configurator = _configuratorsByChannel[channelId]; configurator.Destroy(); _configuratorsByChannel.Remove(channelId); } _configuratorsByChannel = null; _localDispatcher = null; _rootInjector = null; }
public void Removes_Listeners_After_Destruction() { Enum expectedType1 = SupportEvent.Type.TYPE1; Enum expectedType2 = SupportEvent.Type.TYPE2; subject.RelayEvent(expectedType1); subject.ReceiveEvent(expectedType2); subject.Destroy(); localDispatcher.Verify( _localDispatcher => _localDispatcher.RemoveEventListener( It.Is <Enum> (arg1 => arg1 == expectedType1), It.IsAny <Action <IEvent> >() ), Times.Once); channelDispatcher.Verify( _channelDispatcher => _channelDispatcher.RemoveEventListener( It.Is <Enum> (arg1 => arg1 == expectedType2), It.IsAny <Action <IEvent> >() ), Times.Once); }