Last active
August 29, 2015 14:16
-
-
Save johnmmoss/311700a22e4b63df90ed to your computer and use it in GitHub Desktop.
Example Specflow steps
This file contains hidden or 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
[Binding] | |
public class UserAccountSteps | |
{ | |
[Given(@"I am on the register page")] | |
public void GivenIAmOnTheRegisterPage() | |
{ | |
var homePage = ScenarioContext.Current.Get<HomePage>(); | |
var registerPage = homePage.GoToRegisterPage(); | |
ScenarioContext.Current.Set(registerPage); | |
} | |
[Given(@"I have entered a Username of '(.*)' and a password of '(.*)'")] | |
public void GivenIHaveEnteredAUsernameOfAndAPasswordOf(string username, string password) | |
{ | |
var registerPage = ScenarioContext.Current.Get<RegisterPage>(); | |
registerPage.EnterDetails(username, password); | |
} | |
[When(@"I press register")] | |
public void WhenIPressRegister() | |
{ | |
var registerPage = ScenarioContext.Current.Get<RegisterPage>(); | |
registerPage.ClickRegister(); | |
} | |
[Then(@"a new account is created with a username of a Username of '(.*)'")] | |
public void ThenANewAccountIsCreatedWithAUsernameOfAUsernameOf(string username) | |
{ | |
using (var context = new SpecflowTestContext()) | |
{ | |
var allUserProfiles = context.UserProfiles.ToList(); | |
Assert.That(allUserProfiles.Count, Is.EqualTo(1)); | |
Assert.That(allUserProfiles.First().UserName, Is.EqualTo(username)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment