public void ShouldKeepCountOfSubscriptions() { var coursier = new Coursier(); var subOne = coursier.Subscribe <TestMessageOne>(msg => { }); coursier.Subscribe <TestMessageOne>(msg => { }); Assert.Equal(2, coursier.SubscriptionCount <TestMessageOne>()); coursier.Unsubscribe <TestMessageOne>(subOne); Assert.Equal(1, coursier.SubscriptionCount <TestMessageOne>()); }
public void ShouldNotReceiveMessageIfUnSubscribed() { var coursier = new Coursier(); var msgReceived = false; var token = coursier.Subscribe <TestMessageOne>(msg => { msgReceived = true; }); coursier.Unsubscribe <TestMessageOne>(token); coursier.Publish(new TestMessageOne(this)); Assert.False(msgReceived); }