Performing an action with 'When'

In the Given, When, Then setup, the When step is for you to perform the action you are interested in against the System Under Test (SUT).

Consider our simple spec again:

📘

Given a car is started, when the car is stopped, then the engine is stopped.

To perform the action, "when the car is stopped," we can override SpecsFor's When method, and call the Stop method on our SUT:

protected override void When()
{
  //When: perform an action, in this case, stopping the car.
  SUT.Stop();
}

Did this page help you?