public async Task Post_CreateClientWithInvalidInputShouldReturnBadRequest(TestClientInputModel model) { var client = this.factory.CreateClientWithJwtAuthentication(); var response = await client.PostAsJsonAsync("/api/clients/create", model, new JsonSerializerOptions() { IgnoreNullValues = true }); Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode); Assert.Equal("application/problem+json", response.Content.Headers.ContentType.MediaType); }
public async Task Post_CreateClientWithoutAuthenticatedUserShouldReturnUnauthorized() { var model = new TestClientInputModel() { FirstName = "Ivan", LastName = "Ivanov", Address = "Sofia" }; var client = this.factory.CreateClient(); var response = await client.PostAsJsonAsync("/api/clients/create", model, new JsonSerializerOptions() { IgnoreNullValues = true }); Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); }
public async Task Post_CreateClientShouldWorkCorrectly() { var model = new TestClientInputModel() { FirstName = "Gosho", LastName = "Ivanov", Address = "Ruse" }; var client = this.factory.CreateClientWithJwtAuthentication(); var response = await client.PostAsJsonAsync("/api/clients/create", model, new JsonSerializerOptions() { IgnoreNullValues = true }); Assert.Equal(HttpStatusCode.OK, response.StatusCode); Assert.Equal("application/json", response.Content.Headers.ContentType.MediaType); var result = await response.Content.ReadAsStringAsync(); Assert.NotNull(result); }