# Bind remaining stepsÂ¶

âŹ˛ď¸Ź 10 minutes

In this step youâ€™ll bind the remaining steps of the scenario.

1- Similar to the previous page , navigate to the bindings from the feature file by right-clicking the second Given step â€śAnd the second number is 70â€ť and select either the â€śGo To Definitionâ€ť or the â€śGo To Step Definitionâ€ť command. Alternatively you can open the `CalculatorStepDefinitions.cs` directly.

2- Implement the binding of the second step â€śAnd the second number is 70â€ť by replacing the code of the `GivenTheSecondNumberIs` method with the below:

```    [Given("the second number is (.*)")]
public void GivenTheSecondNumberIs(int number)
{
_calculator.SecondNumber = number;
}
```

*We use the â€śAndâ€ť keyword in the Gherkin scenario for better readability. The â€śAndâ€ť keyword will be interpreted as â€śGivenâ€ť, â€śWhenâ€ť or â€śThenâ€ť depending on the previous step(s) in the scenario. In this example the â€śAnd the second number is 70â€ť is interpreted as a â€śGivenâ€ť step because the previous step is a â€śGivenâ€ť step.

3- Next, implement the binding of the third step, â€śWhen the two numbers are addedâ€ť, by replacing the code of the `WhenTheTwoNumbersAreAdded` method with the below. The method must have a `When` attribute, as it belongs to the â€śWhenâ€ť step in the scenario.

```    private int _result;

[When("the two numbers are added")]
public void WhenTheTwoNumbersAreAdded()
{
_result = _calculator.Add();
}
```

This implementation calls the `Add` method of the calculator. Note that the result of the addition is not stored by the calculator in a property/field but it is returned to the caller. Itâ€™s a good idea to store the returned value in a field so that we can work with the result afterwards.

4- Implement the binding of the last step, â€śThen the result should be 120â€ť, by replacing the code of the `ThenTheResultShouldBe` method. The method must have a `Then` attribute, as it belongs to a â€śThenâ€ť step in the scenario.

Add a namespace using for FluentAssertions at the top of the file:

```using FluentAssertions;
```

Use the below code for implementation of the â€śThenâ€ť step which validates if the result of the addition matches the expected value (using the FluentAssertions library).

```    [Then("the result should be (.*)")]
public void ThenTheResultShouldBe(int result)
{
_result.Should().Be(result);
}
```

After implementing all step definitions and cleaning up the file you should have the following code:

```using FluentAssertions;
using TechTalk.SpecFlow;

namespace SpecFlowCalculator.Specs.Steps
{
[Binding]
public sealed class CalculatorStepDefinitions
{
// For additional details on SpecFlow step definitions see https://go.specflow.org/doc-stepdef

private readonly ScenarioContext _scenarioContext;

private readonly Calculator _calculator = new Calculator();
private int _result;

public CalculatorStepDefinitions(ScenarioContext scenarioContext)
{
_scenarioContext = scenarioContext;
}

[Given("the first number is (.*)")]
public void GivenTheFirstNumberIs(int number)
{
_calculator.FirstNumber = number;
}

[Given("the second number is (.*)")]
public void GivenTheSecondNumberIs(int number)
{
_calculator.SecondNumber = number;
}

[When("the two numbers are added")]
public void WhenTheTwoNumbersAreAdded()
{
_result = _calculator.Add();
}

[Then("the result should be (.*)")]
public void ThenTheResultShouldBe(int result)
{
_result.Should().Be(result);
}
}
}
```

5- Build the solution. The build should succeed.

6- Run the test again.

The test should execute and fail, this is expected. In the Test Detail Summary pane of Test Explorer you can see that a NotImplementedException has been thrown in the Add method of the calculator.

7- Click on the â€śOpen additional output for this resultâ€ť below the stack trace to see a more detailed log of the scenario.

You can see that the first two â€śGivenâ€ť steps executed successfully and the â€śWhen the two numbers are addedâ€ť step failed with an error. This is because the addition method of the calculator is not implemented yet.

đź“„ In the next step youâ€™ll fix the implementation of the calculator to fix this error.