Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Feature: RegisterUser
- In order to register a user successfully
- A valid username, email, password (and confirmation password) must be entered
- @register
- Scenario: Valid Register User
- Given I have entered a username "testing", an email "testing@gmail.com", a password "123456" and a confirmation password "123456"
- When I press submit
- Then the response code should be 200
- And the user should be added to the database with verfied set to False
- Background:
- Given I have registered a user "testing", "testing@gmail.com", "123456" and "123456"
- @register
- Scenario: Username Already Taken
- Given I have entered a username "testing", an email "testing1@gmail.com", a password "123456" and a confirmation password "123456"
- When I press submit
- Then the response code should be 400
- using NUnit.Framework;
- using System;
- using System.Net.Http;
- using TechTalk.SpecFlow;
- namespace Tests.Specs
- {
- [Binding]
- public class RegisterUserSteps
- {
- private RegisterUserModel userInfo = new RegisterUserModel();
- private RegisterUserController user = new RegisterUserController()
- {
- Request = new HttpRequestMessage(),
- Configuration = new System.Web.Http.HttpConfiguration()
- };
- private ApiResponse response = new ApiResponse();
- private static string userTableName = "usersTable";
- private static string userTablePartitionKey = "USER_INFO";
- private static string userTableRowKey = "testing@gmail.com";
- [Given(@"I have entered a username ""(.*)"", an email ""(.*)"", a password ""(.*)"" and a confirmation password ""(.*)""")]
- public void GivenIHaveEnteredAUsernameAnEmailAPasswordAndAConfirmationPassword(string p0, string p1, string p2, string p3)
- {
- userInfo.Username = p0;
- userInfo.Email = p1;
- userInfo.Password = p2;
- userInfo.ConfirmPassword = p3;
- }
- [When(@"I press submit")]
- public void WhenIPressSubmit()
- {
- response = user.Register(userInfo);
- }
- [Then(@"the response code should be (.*)")]
- public void ThenTheResponseCodeShouldBe(int p0)
- {
- Assert.AreEqual(p0, response.Status);
- }
- [Then(@"the user should be added to the database with verfied set to False")]
- public void ThenTheUserShouldBeAddedToTheDatabaseWithVerfiedSetToFalse()
- {
- UserEntity user = AzureUtilities.RetrieveEntity<UserEntity>(userTableName, userTablePartitionKey, userTableRowKey);
- Assert.IsNotNull(user);
- Assert.AreEqual(userInfo.Username, user.Username);
- Assert.AreEqual(userInfo.Email, user.RowKey);
- Assert.IsFalse(user.Verified);
- }
- [Given(@"I have registered a user ""(.*)"", ""(.*)"", ""(.*)"" and ""(.*)""")]
- public void GivenIHaveRegisteredAUserAnd(string p0, string p1, string p2, string p3)
- {
- //Using methods here that have been defined in previous steps
- GivenIHaveEnteredAUsernameAnEmailAPasswordAndAConfirmationPassword(p0, p1, p2, p3);
- WhenIPressSubmit();
- ThenTheResponseCodeShouldBe(200);
- }
Add Comment
Please, Sign In to add comment