示例#1
0
        public async Task HandleCaretakerRequest_DeclineRequest_Succeeds()
        {
            (await _client.AuthenticateUserAsync("twilliams", "password")).AddAuthorization(_httpClient);

            SuccessfulRequestDto response = null;

            Assert.Null(await Record.ExceptionAsync(async() =>
                                                    response = await _client.Caretaker_HandleCaretakerRequestAsync(Guid.Parse("f61ee92d-792e-45dd-a664-309178a71830"),
                                                                                                                   new HandleCaretakerForCustomerRequestDto {
                AcceptRequest = false
            })));
            Assert.NotNull(response);

            PendingCaretakerRequestsDto response1 = null;

            Assert.Null(await Record.ExceptionAsync(async() => response1 = await _client.Caretaker_GetPendingCaretakerRequestsAsync()));
            Assert.NotNull(response1);
            Assert.Equal(2, response1.CaretakerRequests.Count());

            AssignedCustomersForCaretakerDto response2 = null;

            Assert.Null(await Record.ExceptionAsync(async() => response2 = await _client.Caretaker_GetAssignedCustomersAsync()));
            Assert.NotNull(response2);
            Assert.Empty(response2.Customers);
        }
        public async Task AddCaretakerForCustomer_ValidRequest_Successful()
        {
            (await _client.AuthenticateUserAsync("fbrown", "password")).AddAuthorization(_httpClient);

            SuccessfulRequestDto response = null;

            Assert.Null(await Record.ExceptionAsync(async() =>
                                                    response = await _client.Customer_AddCaretakerForCustomerAsync(
                                                        new AddCaretakerForCustomerDto {
                CaretakerUsername = "******"
            })));
            Assert.NotNull(response);


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

            PendingCaretakerRequestsDto response1 = null;

            Assert.Null(await Record.ExceptionAsync(async() =>
                                                    response1 = await _client.Caretaker_GetPendingCaretakerRequestsAsync()));
            Assert.NotNull(response1);
            Assert.Single(response1.CaretakerRequests);
            Assert.Contains(response1.CaretakerRequests, x =>
                            x.Customer.FirstName == "Frank" && x.Customer.LastName == "Brown" &&
                            x.Customer.Username == "fbrown" && x.Customer.PhoneNumber == "+4418821001");
        }
示例#3
0
        public async Task GetPendingCaretakerRequests_ValidRequest_Succeeds()
        {
            (await _client.AuthenticateUserAsync("twilliams", "password")).AddAuthorization(_httpClient);

            PendingCaretakerRequestsDto response = null;

            Assert.Null(await Record.ExceptionAsync(async() => response = await _client.Caretaker_GetPendingCaretakerRequestsAsync()));
            Assert.NotNull(response);
            Assert.Equal(3, response.CaretakerRequests.Count());

            foreach (var request in response.CaretakerRequests)
            {
                Assert.NotNull(request);
                Assert.NotNull(request.Customer);
                Assert.NotNull(request.Customer.FirstName);
                Assert.NotNull(request.Customer.LastName);
                Assert.NotNull(request.Customer.Username);
                Assert.InRange(request.Timestamp, request.Timestamp, DateTime.UtcNow);
            }
        }
        public async Task AddCaretaker_ExistingRequest_Fails()
        {
            (await _client.AuthenticateUserAsync("fbrown", "password")).AddAuthorization(_httpClient);

            SuccessfulRequestDto response = null;

            Assert.NotNull(await Record.ExceptionAsync(async() =>
                                                       response = await _client.Customer_AddCaretakerForCustomerAsync(
                                                           new AddCaretakerForCustomerDto {
                CaretakerUsername = "******"
            })));
            Assert.Null(response);


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

            PendingCaretakerRequestsDto response1 = null;

            Assert.Null(await Record.ExceptionAsync(async() =>
                                                    response1 = await _client.Caretaker_GetPendingCaretakerRequestsAsync()));
            Assert.NotNull(response1);
            Assert.Empty(response1.CaretakerRequests);
        }