A policy has two requirements, A and B, each with its own handler. What is a potential bug in the handler for requirement A if it doesn't explicitly fail when its condition is not met?
.NET interview question for Advanced practice.
Answer
The handler should explicitly call context.Fail() to ensure that the entire policy fails immediately if its specific condition is not met.
Explanation
The correct answer is D. The bug is a matter of intent. By not calling context.Fail(), the handler is only voting for success but never for failure. If the policy requires RequirementA to be definitively met by this handler's logic, then not meeting the condition should result in a context.Fail() call. Otherwise, the system might find another handler for RequirementA that succeeds, or if there are none, RequirementA will not be met, and the overall policy will fail anyway. Explicitly calling Fail makes the handler's decision final and prevents other handlers from overriding a failure.