Created
April 4, 2012 14:13
-
-
Save adiel/2301407 to your computer and use it in GitHub Desktop.
Register custom scenario-scoped dependencies in SpecFlow - Coypu example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using BoDi; | |
using Coypu; | |
using OpenQA.Selenium; | |
using TechTalk.SpecFlow; | |
namespace SpecflowContainerContext | |
{ | |
[Binding] | |
public class Hooks | |
{ | |
private readonly IObjectContainer _objectContainer; | |
private BrowserSession _browser; | |
public Hooks(IObjectContainer objectContainer) | |
{ | |
_objectContainer = objectContainer; | |
} | |
[BeforeScenario] | |
public void Before() | |
{ | |
_browser = new BrowserSession(new SessionConfiguration { AppHost = "featurist.co.uk" }); | |
_objectContainer.RegisterInstanceAs(_browser); | |
} | |
[AfterScenario] | |
public void AfterScenario() | |
{ | |
_browser.Dispose(); | |
} | |
} | |
[Binding] | |
public class SomeSteps | |
{ | |
private readonly BrowserSession _browser; | |
public SomeSteps(BrowserSession browser) | |
{ | |
_browser = browser; | |
} | |
[When("Hello world")] | |
public void HelloWorld() | |
{ | |
_browser.Visit("/"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment