Exemplo n.º 1
0
        public void LoginFailure(string email, string password, bool existingEmail, HttpClient client, HttpResponseMessage loginRsp, ErrorContainer errors)
        {
            $"Given I have an instance of httpclient"
            .x(() => client = _server.Http());

            if (existingEmail)
            {
                $"And my email should exists in system"
                .x(() => _server.Services.EnsureUserRecordExists(new UserRecord
                {
                    Id           = Guid.NewGuid().ToString(),
                    Email        = email,
                    PasswordHash = Guid.NewGuid().ToString()
                }));
            }

            $"When I submit my login details"
            .x(async() => loginRsp = await client.PostFormDataAsync("/accounts/login/", new LoginRequest
            {
                Email    = email,
                Password = password
            }));
            $"Then I should receive a bad request status code"
            .x(() => loginRsp.StatusCode.ShouldBe(HttpStatusCode.BadRequest));
            $"And the response should contain error collection"
            .x(async() => errors = await loginRsp.ReadAsAsync <ErrorContainer>());
            $"And error should contain correct error message"
            .x(() => errors.HasError("Email",
                                     "Failed to login. Please ensure you entered correct email and password."));
        }
Exemplo n.º 2
0
 public void RegistrationFailedOnWrongInput(HttpClient http,
                                            HttpResponseMessage rsp,
                                            ErrorContainer errors)
 {
     $"Given I have an instance of HttpClient"
     .x(() => http = _server.Http());
     $"When I submit an empty form"
     .x(async() => rsp = await http.PostFormDataAsync("/accounts/registration", new RegisterUser()));
     $"Then I should get a response with status code bad request"
     .x(() => rsp.StatusCode.ShouldBe(HttpStatusCode.BadRequest));
     $"And I should get collection of errors"
     .x(async() => errors = await rsp.ReadAsAsync <ErrorContainer>());
     $"And errors should contain error message for empty email"
     .x(() => errors.HasError("Email", "Email is required"));
     $"And errors should contain error message for empty password"
     .x(() => errors.HasError("Password", "Password is required"));
 }
Exemplo n.º 3
0
 public void LoginValidation(HttpClient client, HttpResponseMessage loginRsp, ErrorContainer errors)
 {
     $"Given I have an instance of httpclient"
     .x(() => client = _server.Http());
     $"When I sunmit an empty login form"
     .x(async() => loginRsp = await client.PostFormDataAsync("/accounts/login/", new LoginRequest()));
     $"Then I should get a badrequest status code"
     .x(() => loginRsp.StatusCode.ShouldBe(HttpStatusCode.BadRequest));
     $"And response should have an error container"
     .x(async() => errors = await loginRsp.ReadAsAsync <ErrorContainer>());
     $"And error should contain 2 errors"
     .x(() => errors.Errors.Count.ShouldBe(2));
     $"And error should contain error for empty email"
     .x(() => errors.HasError("Email", "Email is required."));
     $"And error should contain error for empty password"
     .x(() => errors.HasError("Password", "Password is required."));
 }