public void Subscribe_Disposed_Throws() { // arrange var bus = new TukBus(); Action <IEvent> handler = args => { }; // act using (bus) { } bus.Subscribe <FakeEvent1>(handler); }
public void Dispose_Disposes() { // arrange var bus = new TukBus(); const string expected1 = "One"; const string expected2 = "Two"; var actual1 = string.Empty; var actual2 = string.Empty; Action <IEvent> handler1 = args => { actual1 = expected1; }; Action <IEvent> handler2 = args => { actual2 = expected2; }; bus.Subscribe <FakeEvent1>(handler1); bus.Subscribe <FakeEvent2>(handler2); // act using (bus) { } // assert Assert.IsTrue(bus.IsDisposed); }
private static void Main(string[] args) { var bus = new TukBus(); var session = bus.Subscribe <MultipleOfFifteenEvent>(HandleEvent); Console.WriteLine("Outputting multiples of 15 between 1 and 10000..."); Run(bus); Console.ReadLine(); // you could put this in a using statement, but understand that the notification queue may // not be finished yet. This is perfectly fine in eventual consistency situations bus.Dispose(); }