public async Task GetAssignedTasks_InvalidTaskOption_Succeeds() { (await _client.AuthenticateUserAsync("mwilson", "password")).AddAuthorization(_httpClient); CustomerTasksDto response = null; Assert.NotNull(await Record.ExceptionAsync(async() => response = await _client.Customer_GetAssignedTasksAsync((TaskOption)123))); Assert.Null(response); }
public async Task GetAssignedTasks_ValidRequest_Succeeds() { (await _client.AuthenticateUserAsync("mwilson", "password")).AddAuthorization(_httpClient); CustomerTasksDto response = null; Assert.Null(await Record.ExceptionAsync(async() => response = await _client.Customer_GetAssignedTasksAsync(TaskOption.Both))); Assert.NotNull(response); Assert.Empty(response.Tasks); using (var context = _factory.GetKIOTContext()) { var caretaker = context.Caretakers.SingleOrDefault(x => x.Username == "jcole"); Assert.NotNull(caretaker); var customer = context.Customers.SingleOrDefault(x => x.Username == "mwilson"); Assert.NotNull(customer); context.CustomerTasks.Add(new CustomerTask(customer, caretaker, "TestDescription", "TestTitle", DateTime.UtcNow.AddDays(1))); context.SaveChanges(); } response = null; Assert.Null(await Record.ExceptionAsync(async() => response = await _client.Customer_GetAssignedTasksAsync(TaskOption.Both))); Assert.NotNull(response); Assert.Single(response.Tasks); var task = response.Tasks.First(); CustomerTasksDto response1 = null; Assert.Null(await Record.ExceptionAsync(async() => response1 = await _client.Customer_GetAssignedTasksAsync(TaskOption.Finished))); Assert.NotNull(response1); Assert.Empty(response1.Tasks); CustomerTasksDto response2 = null; Assert.Null(await Record.ExceptionAsync(async() => response2 = await _client.Customer_GetAssignedTasksAsync(TaskOption.Unfinished))); Assert.NotNull(response2); Assert.Single(response2.Tasks); Assert.Equal("TestTitle", task.Title); Assert.Equal("TestDescription", task.Description); Assert.InRange(DateTime.UtcNow, task.StartedAt, task.ExpiresAt ?? DateTime.UtcNow); Assert.Equal("jcole", task.AssignedBy); Assert.False(task.Finished); }