public void ReleaseAll_RemovesChannelWhenFailded() { // Arrange Mock <IConnectionManager> manager = new Mock <IConnectionManager>(); Mock <IChannelFactory> factory = new Mock <IChannelFactory>(); factory.Setup(c => c.Create(It.IsAny <string>())).Returns <string>(c => new Channel(c, "", manager.Object)); ChannelList target = new ChannelList(manager.Object, factory.Object); var channel = target.Get("test"); channel.Attach(); target.ReleaseAll(); // Act manager.Raise(c => c.MessageReceived += null, new ProtocolMessage(ProtocolMessage.MessageAction.Error, "test")); // Assert Assert.False(target.Any()); }