public void ExecuteInContext(ManuallyPumpedSynchronizationContext context, Action <Advancer> action) { SynchronizationContext originalContext = SynchronizationContext.Current; try { SynchronizationContext.SetSynchronizationContext(context); Advancer advancer = new Advancer(actions, context); // This is where the tests assertions etc will go... action(advancer); } finally { SynchronizationContext.SetSynchronizationContext(originalContext); } }
internal Advancer(SortedDictionary <int, Action> actions, ManuallyPumpedSynchronizationContext context) { this.actions = actions; this.context = context; }