public async Task ShouldCreateNew() { // Arrange using var server = new WebAppFixture(TodoTaskControllerTests.tasks); using var client = server.CreateClient(); // Act var response = await client.PostAsync( "tasks/new", Serialize(new { name = "Buy an avocado", priority = 1, status = "Completed" })); var result = await response.Content.ReadAsStringAsync(); // Assert Assert.True(response.IsSuccessStatusCode); Assert.NotNull(result); Assert.NotEmpty(result); }
public async Task ShouldReturn400WhenDeleteInvalid() { // Arrange using var server = new WebAppFixture(TodoTaskControllerTests.tasks); using var client = server.CreateClient(); // Act var response = await client.DeleteAsync($"tasks/delete/{tasks[1].Id}"); // Assert Assert.Equal(400, (int)response.StatusCode); }
public async Task ShouldDelete() { // Arrange using var server = new WebAppFixture(TodoTaskControllerTests.tasks); using var client = server.CreateClient(); // Act var response = await client.DeleteAsync($"tasks/delete/{tasks[0].Id}"); // Assert Assert.True(response.IsSuccessStatusCode); }
public async Task ShouldGetAll() { // Arrange using var server = new WebAppFixture(TodoTaskControllerTests.tasks); using var client = server.CreateClient(); // Act var response = await client.GetAsync("tasks/all"); var result = await DeserializeAsync <IEnumerable <TodoTaskDto> >(response.Content); // Assert Assert.True(response.IsSuccessStatusCode); Assert.Collection(result, model => AssertEqualToEntity(model, tasks[0]), model => AssertEqualToEntity(model, tasks[1])); }
public async Task ShouldReturn400WhenNewTaskInvalid() { // Arrange using var server = new WebAppFixture(TodoTaskControllerTests.tasks); using var client = server.CreateClient(); // Act var response = await client.PostAsync( "tasks/new", Serialize(new { name = "Buy an avocado", priority = 0, status = "Completed" })); // Assert Assert.Equal(400, (int)response.StatusCode); }
public async Task ShouldUpdate() { // Arrange using var server = new WebAppFixture(TodoTaskControllerTests.tasks); using var client = server.CreateClient(); // Act var response = await client.PutAsync( $"tasks/update", Serialize(new { id = tasks[0].Id, name = "Buy an avocado", priority = 1, status = "Completed" })); // Assert Assert.True(response.IsSuccessStatusCode); }
public async Task ShouldReturn400WhenUpdateInvalid() { // Arrange using var server = new WebAppFixture(TodoTaskControllerTests.tasks); using var client = server.CreateClient(); // Act var response = await client.PutAsync( $"tasks/update", Serialize(new { id = tasks[0].Id, name = tasks[1].Name, priority = 1, status = "Completed" })); // Assert Assert.Equal(400, (int)response.StatusCode); }
public async Task ShouldReturn400WhenUpdateMissingTask() { // Arrange using var server = new WebAppFixture(TodoTaskControllerTests.tasks); using var client = server.CreateClient(); // Act var response = await client.PutAsync( $"tasks/update", Serialize(new { id = Guid.NewGuid().ToString(), name = "Buy an avocado", priority = 1, status = "Completed" })); // Assert Assert.Equal(400, (int)response.StatusCode); }