public async Task Get_ReturnNotFound() { //Arrange using var client = new TestClientProvider().Client; var nonexistantEmail = "*****@*****.**"; //Act var response = await client.GetAsync($"/user?email={nonexistantEmail}"); //Assert Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); }
public async Task Create_ValidationError() { //Arrange using var client = new TestClientProvider().Client; var newUser = new UserPostRequestDto() { FirstName = "TestFirstName", MiddleName = "TestMiddleName", LastName = "TestLastName", EmailAddress = "TestEmailAddress~yahoo.com", PhoneNumber = "*****@*****.**" }; var stringContent = new StringContent(JsonConvert.SerializeObject(newUser), Encoding.UTF8, "application/json"); //Act var response = await client.PostAsync($"/user/", stringContent); //Assert Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); }
public async Task Get_ReturnValues() { // Arrange using var client = new TestClientProvider().Client; var userEmail = "*****@*****.**"; // Act var response = await client.GetAsync($"/user?email={userEmail}"); // Assert response.EnsureSuccessStatusCode(); var stringData = response.Content.ReadAsStringAsync().Result; Assert.Equal(HttpStatusCode.OK, response.StatusCode); var options = new JsonSerializerOptions { PropertyNameCaseInsensitive = true }; var user = System.Text.Json.JsonSerializer.Deserialize <UserGetResponseDto>(stringData, options); Assert.Equal(userEmail, user.EmailAddress); Assert.Equal("Chris Colin Stafford", user.Name); }