public async Task GivenNoEmailAddress_RespondsWithModelState() { var url = GetAuthenticateUrl(); const string password = "******"; var authenticate = new TestAuthenticateRequestBuilder() .WithPassword(password) .Build(); // Act var response = await HttpClient.PostAsJsonAsync(url, authenticate); // Assert var responseData = await response.Content.ReadFromJsonAsync <ValidationResponse>(); Assert.Multiple(() => { Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); DiagnoseaAssert.Contains( responseData.Errors, nameof(AuthenticateRequest.EmailAddress), ExceptionMessages.Interchange.Required); }); }
public async Task GivenNoUserId_RespondsWithBadRequestAndModelState() { // Arrange SetStandardBearerToken(); var request = new CreateLicenseRequest(); // Act var response = await HttpClient.PostAsJsonAsync(_url, request); // Assert var responseData = await response.Content.ReadFromJsonAsync <ValidationResponse>(); Assert.Multiple(() => { Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); DiagnoseaAssert.Contains(responseData.Errors, nameof(CreateLicenseRequest.UserId), ExceptionMessages.Interchange.Required); }); }
public async Task GivenNoPassword_RespondsWithModelState() { var url = GetAuthenticateUrl(); const string emailAddress = "*****@*****.**"; var authenticate = new TestAuthenticateRequestBuilder() .WithEmailAddress(emailAddress) .Build(); // Act var response = await HttpClient.PostAsJsonAsync(url, authenticate); // Assert var responseData = await response.Content.ReadFromJsonAsync <ValidationResponse>(); Assert.Multiple(() => { Assert.AreEqual(HttpStatusCode.BadRequest, response.StatusCode); DiagnoseaAssert.Contains(responseData.Errors, nameof(AuthenticateRequest.Password), ExceptionMessages.Interchange.Required); }); }
public async Task GivenNoPassword_RespondsWithModelState() { var url = GetRegisterUrl(); const string emailAddress = "*****@*****.**"; const string password = null; var register = new TestRegisterRequestBuilder() .WithEmailAddress(emailAddress) .WithPassword(password) .Build(); // Act var response = await HttpClient.PostAsJsonAsync(url, register); // Assert var responseData = await response.Content.ReadFromJsonAsync <ValidationResponse>(); Assert.Multiple(() => { Assert.That(response.StatusCode, Is.EqualTo(HttpStatusCode.BadRequest)); DiagnoseaAssert.Contains(responseData.Errors, nameof(RegisterRequest.Password), ExceptionMessages.Interchange.Required); }); }