Skip to content

Instantly share code, notes, and snippets.

@gasparnagy
Created February 17, 2017 08:33
Show Gist options
  • Save gasparnagy/5cd2597aa45304b991489acb7a40fd44 to your computer and use it in GitHub Desktop.
Save gasparnagy/5cd2597aa45304b991489acb7a40fd44 to your computer and use it in GitHub Desktop.
[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
// We use the ScenarioContext property defined in the Steps base class
// instead of ScenarioContext.Current, because ScenarioContext.Current
// does not work for parallel execution.
ScenarioContext["userContext"] = new UserContext
{
UserName = userName,
Role = "Administrator"
};
}
}
[Binding]
public class ShareDataWithScenarioContextSteps2 : Steps
{
[When(@"the user opens the assigned tasks")]
public void WhenTheUserOpensTheAssignedTasks()
{
// Read the user information from the current scenario context
var userContext = (UserContext)ScenarioContext["userContext"];
var tasks = TaskManagement.GetAssignedTasks(userContext.UserName);
//...
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment