コード例 #1
0
        public async Task DeleteAssignedCaretaker_ValidRequest_Successful()
        {
            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.IsCaredForBys.Add(new CaretakerForCustomer(caretaker.Id, customer.Id));
                context.SaveChanges();
            }

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

            SuccessfulRequestDto response = null;

            Assert.Null(await Record.ExceptionAsync(async() =>
                                                    response = await _client.Customer_DeleteAssignedCaretakerAsync(Guid.Parse("e0e26424-f4cd-4400-bc78-28b0bfef729a"))));
            Assert.NotNull(response);

            AssignedCaretakersForCustomerDto response1 = null;

            Assert.Null(await Record.ExceptionAsync(async() =>
                                                    response1 = await _client.Customer_GetAssignedCaretakersAsync()));
            Assert.NotNull(response1);
            Assert.Empty(response1.Caretakers);
        }
コード例 #2
0
        public async Task GetAssignedCaretakers_ValidRequest_Successful()
        {
            (await _client.AuthenticateUserAsync("mwilson", "password")).AddAuthorization(_httpClient);

            AssignedCaretakersForCustomerDto response = null;

            Assert.Null(await Record.ExceptionAsync(async() =>
                                                    response = await _client.Customer_GetAssignedCaretakersAsync()));
            Assert.NotNull(response);
            Assert.Empty(response.Caretakers);

            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.IsCaredForBys.Add(new CaretakerForCustomer(caretaker.Id, customer.Id));
                context.SaveChanges();
            }

            response = null;
            Assert.Null(await Record.ExceptionAsync(async() =>
                                                    response = await _client.Customer_GetAssignedCaretakersAsync()));
            Assert.NotNull(response);
            Assert.Single(response.Caretakers);
        }
コード例 #3
0
        public async Task AuthenticateUser_ValidCredentials_AllowsAuthorizedAccess()
        {
            var dto = await _client.AuthenticateUserAsync("mwilson", "password");

            Assert.NotNull(dto);
            _httpClient.AddAuthorization(dto);

            AssignedCaretakersForCustomerDto dto2 = null;
            var exception2 = await Record.ExceptionAsync(async() =>
            {
                dto2 = await _client.Customer_GetAssignedCaretakersAsync();
            });

            Assert.Null(exception2);
            Assert.NotNull(dto2);
        }
コード例 #4
0
        public async Task DeleteAssignedCaretaker_InvalidCaretaker_Successful()
        {
            (await _client.AuthenticateUserAsync("mwilson", "password")).AddAuthorization(_httpClient);

            SuccessfulRequestDto response = null;

            Assert.NotNull(await Record.ExceptionAsync(async() =>
                                                       response = await _client.Customer_DeleteAssignedCaretakerAsync(Guid.Parse("e0e26424-f4cd-4400-bc78-28b0bfef729a"))));
            Assert.Null(response);

            AssignedCaretakersForCustomerDto response1 = null;

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