Пример #1
0
        public async Task GetCustomerTasks_ExistingTask_ReturnsNonEmptyCollection()
        {
            using (var context = _factory.GetKIOTContext())
            {
                var(customer, caretaker) = context.AddCaretakerForCustomer("jcole", "mwilson");
                var task = new CustomerTask(customer, caretaker, "TestDescription", "TestTitle", null);
                Assert.False(task.TaskFinished);
                context.CustomerTasks.Add(task);
                context.SaveChanges();
            }

            (await _client.AuthenticateUserAsync("jcole", "password")).AddAuthorization(_httpClient);

            CustomerTasksForCaretakerDto response = null;

            Assert.Null(await Record.ExceptionAsync(async() =>
                                                    response = await _client.Caretaker_GetCustomerTasksAsync(Guid.Parse("d53a5412-efdd-4905-9f5d-5c2a624726a2"))));
            Assert.NotNull(response);
            Assert.Single(response.Tasks);
            var responseTask = response.Tasks.First();

            Assert.Equal("TestTitle", responseTask.Title);
            Assert.Equal("TestDescription", responseTask.Description);
            Assert.False(responseTask.Finished);
        }
Пример #2
0
        public async Task GetCustomerTasks_NonAssignedCustomer_Fails()
        {
            (await _client.AuthenticateUserAsync("jcole", "password")).AddAuthorization(_httpClient);

            CustomerTasksForCaretakerDto response = null;

            Assert.NotNull(await Record.ExceptionAsync(async() =>
                                                       response = await _client.Caretaker_GetCustomerTasksAsync(Guid.Parse("d53a5412-efdd-4905-9f5d-5c2a624726a2"))));
            Assert.Null(response);
        }
Пример #3
0
        public async Task GetCustomerTasks_NoRegisteredTasks_ReturnsEmptyCollection()
        {
            using (var context = _factory.GetKIOTContext())
            {
                _ = context.AddCaretakerForCustomer("jcole", "mwilson");
            }

            (await _client.AuthenticateUserAsync("jcole", "password")).AddAuthorization(_httpClient);

            CustomerTasksForCaretakerDto response = null;

            Assert.Null(await Record.ExceptionAsync(async() =>
                                                    response = await _client.Caretaker_GetCustomerTasksAsync(Guid.Parse("d53a5412-efdd-4905-9f5d-5c2a624726a2"))));
            Assert.NotNull(response);
            Assert.Empty(response.Tasks);
            Assert.NotNull(response.Customer);
            Assert.Equal("mwilson", response.Customer.Username);
            Assert.Equal("Matt", response.Customer.FirstName);
            Assert.Equal("Wilson", response.Customer.LastName);
            Assert.Equal("+4418821000", response.Customer.PhoneNumber);
        }