public void ModuleHost_DefaultSortPriority() { // Given var events = new DummyEvents(); events.OneWay += DummyHandler; var m1 = new DummyModBase(1); m1.Initialize(events); var m2 = new DummyModBase(2); m2.Initialize(events); var loader = new Mock <ILoader <IDummyEvents> >(); var host = new TestModuleHost(loader.Object, events); // When/Then - Exception thrown if execution is out of sequence var args = new DummyEventArgs { ExecutionCount = 0 }; host.InvokeOneWayEvent(args); }
public void ModuleHost_ShouldSortDelegatesByPriority() { // Given var events = new DummyEvents(); var m0 = new DummyMod1(); m0.Initialize(events); var m1 = new DummyMod1(); m1.Initialize(events); var m2 = new DummyMod2(0); m2.Initialize(events); var loader = new Mock <ILoader <IDummyEvents> >(); var host = new TestModuleHost(loader.Object, events); // When/Then - Exception thrown if execution is out of sequence var args = new DummyEventArgs { ExecutionCount = 0 }; host.InvokeOneWayEvent(args); }
private void DummyHandler(DummyEventArgs e) { if (ExpectedExecutionCount >= 0 && e.ExecutionCount != ExpectedExecutionCount) { throw new Exception($"Expecting execution order of {ExpectedExecutionCount} nut was {e.ExecutionCount}"); } e.ExecutionCount++; }
private void DummyHandler(DummyEventArgs e) { if (e.ExecutionCount > 0) { throw new Exception(); } e.ExecutionCount++; }
public void InvokeOneWayEvent(DummyEventArgs args = null) { try { InvokeModuleEvent(Events.OneWay, args ?? new DummyEventArgs()); } catch (Exception) { throw; } }