Follow-up from #451 (FT-2, #307).
Problem
BuildContext.RegisterCancellationHandler / UnregisterCancellationHandler — the two methods BuildManager.CancellationHandler exists to delegate to — have no positive coverage. The only spec on the facade (Cancellation_handler_facade_is_a_no_op_without_an_active_context) exercises the null-context path.
They can't be tested as written: registered handlers only run from the Console.CancelKeyPress subscription, and ConsoleCancelEventArgs has no public constructor, so the event can't be raised from a spec.
Outcome
A registered handler can be shown to run, and an unregistered one shown not to, without depending on a real Ctrl+C.
Needs a seam — e.g. an internal void InvokeCancellationHandlers() on BuildContext that the CancelKeyPress subscription calls, so specs can drive the same path. Worth settling before FT-4/5/6 move more per-run services onto the context.
Acceptance criteria
Follow-up from #451 (FT-2, #307).
Problem
BuildContext.RegisterCancellationHandler/UnregisterCancellationHandler— the two methodsBuildManager.CancellationHandlerexists to delegate to — have no positive coverage. The only spec on the facade (Cancellation_handler_facade_is_a_no_op_without_an_active_context) exercises the null-context path.They can't be tested as written: registered handlers only run from the
Console.CancelKeyPresssubscription, andConsoleCancelEventArgshas no public constructor, so the event can't be raised from a spec.Outcome
A registered handler can be shown to run, and an unregistered one shown not to, without depending on a real Ctrl+C.
Needs a seam — e.g. an
internal void InvokeCancellationHandlers()onBuildContextthat theCancelKeyPresssubscription calls, so specs can drive the same path. Worth settling before FT-4/5/6 move more per-run services onto the context.Acceptance criteria
BuildManager.CancellationHandlerwith an active context runs the handler when cancellation is signalled.internal— noInternalsVisibleToto non-test assemblies.