Skip to content

Instantly share code, notes, and snippets.

View gasparnagy's full-sized avatar

Gáspár Nagy gasparnagy

View GitHub Profile
[Binding]
public class CalculatorSteps
{
private readonly ScenarioContext scenarioContext;
public CalculatorSteps(ScenarioContext scenarioContext)
{
this.scenarioContext = scenarioContext;
}
[Given(@"I have entered (.*) into the calculator")]
public void GivenIHaveEnteredIntoTheCalculator(int operand)
{
((Calculator)ScenarioContext.Current["calc"]).Enter(operand);
}
[Binding]
public class CalculatorSteps
{
private readonly Calculator calculator = new Calculator();
[Given(@"I have entered (.*) into the calculator")]
public void GivenIHaveEnteredIntoTheCalculator(int operand)
{
calculator.Enter(operand);
}
Feature: Multiplication
Scenario Outline: Add two numbers
Given I have entered <a> into the calculator
And I have entered <b> into the calculator
When I press multiply
Then the result should be <result> on the screen
Examples:
| case | a | b | result |
Feature: Addition
Scenario Outline: Add two numbers
Given I have entered <a> into the calculator
And I have entered <b> into the calculator
When I press add
Then the result should be <result> on the screen
Examples:
| case | a | b | result |
public static class TestDependencies
{
[ScenarioDependencies]
public static ContainerBuilder CreateContainerBuilder()
{
// create container with the runtime dependencies
var builder = Dependencies.CreateContainerBuilder();
//TODO: add customizations, stubs required for testing
public class ControllerContext
{
public CalculatorController Controller { get; private set; }
public ControllerContext()
{
var containerBuilder = Dependencies.CreateContainerBuilder(); // invoke runtime dependency configuration
//TODO: apply test-specific customizations if needed
var container = containerBuilder.Build(); // create container
Controller = container.Resolve<CalculatorController>();
public class ControllerContext
{
public CalculatorController Controller { get; } = new CalculatorController();
...
}
[Binding]
public class CalculatorSteps
{
public CalculatorSteps(ControllerContext controllerContext)
[Binding]
public class CalculatorSteps
{
private readonly CalculatorController controller = new CalculatorController();
...
}
[Binding]
public class ShareDataWithScenarioContextSteps1 : Steps
{
[Given(@"an Administrator has logged in")]
public void GivenAnAdministratorHasLoggedIn()
{
var userName = UserManagement.CreateAdminUser();
UserManagement.Login(userName);
// Save data about the current user into the current scenario context