コード例 #1
0
        public async Task PostCalendarBadRequest_EndBeforeStart()
        {
            // arrange
            TestClient   testClient  = new TestClient();
            const string endpoint    = "calendar/post/?id=testpatient";
            string       requestBody = JsonConvert.SerializeObject(new CalendarEntry()
            {
                Start = DateTime.Now, End = DateTime.Now.AddDays(-1)
            });
            const HttpStatusCode expectedStatusCode = HttpStatusCode.BadRequest;
            const string         expectedResponse   = "Invalid start date.";

            testClient.AddHeader("ApiKey", "testcarer");

            // act
            HttpResponseMessage response = await testClient.PostRequest(endpoint, body : requestBody);

            string actualResponse = await response.Content.ReadAsStringAsync();

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #2
0
        public async Task PutCalendarNotFound()
        {
            // arrange
            TestClient   testClient  = new TestClient();
            const string endpoint    = "calendar/put/?id=thisdoesntexist";
            string       requestBody = JsonConvert.SerializeObject(new CalendarEntry()
            {
                Start = DateTime.Now.AddDays(-1)
            });
            const HttpStatusCode expectedStatusCode = HttpStatusCode.NotFound;
            const string         expectedResponse   = "Could not find an entry with that id.";

            testClient.AddHeader("ApiKey", "testcarer");

            // act
            HttpResponseMessage response = await testClient.PutRequest(endpoint, body : requestBody);

            string actualResponse = await response.Content.ReadAsStringAsync();

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #3
0
        public async Task GetCalendarOkRequest_Patient()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "calendar/patientget/";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.OK;

            testClient.AddHeader("ApiKey", "testpatient");

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            string responseBody = await response.Content.ReadAsStringAsync();

            ICollection <CalendarEntry> entries = JsonConvert.DeserializeObject <ICollection <CalendarEntry> >(responseBody);
            bool withinRange = true;

            foreach (CalendarEntry e in entries)
            {
                if (e.Start.Day < DateTime.Now.Day || e.Start.Day > DateTime.Now.Day + 1)
                {
                    withinRange = false;
                }
            }
            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.True(withinRange);
        }
コード例 #4
0
        public async Task PutCalendarOkRequest()
        {
            // arrange
            TestClient   testClient  = new TestClient();
            const string endpoint    = "calendar/put/?id=testpatient";
            string       requestBody = JsonConvert.SerializeObject(new CalendarEntry()
            {
                Start = DateTime.Now.AddDays(1), End = DateTime.Now.AddDays(2)
            });
            const HttpStatusCode expectedStatusCode = HttpStatusCode.OK;
            const string         expectedResponse   = "Calendar entry updated successfully.";

            testClient.AddHeader("ApiKey", "testcarer");

            // act
            HttpResponseMessage response = await testClient.PutRequest(endpoint, body : requestBody);

            string actualResponse = await response.Content.ReadAsStringAsync();

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #5
0
ファイル: AuthFilterTests.cs プロジェクト: crkaz/iris-server
        public async Task FormalCarerRequests()
        {
            // arrange
            TestClient testClient = new TestClient();

            testClient.AddHeader("ApiKey", "testcarer_formal");
            string endpoint;

            // act
            endpoint = "test/authfilterpatient";
            HttpResponseMessage patientResponse = await testClient.GetRequest(endpoint);

            endpoint = "test/authfilterinformalcarer";
            HttpResponseMessage formalCarerResponse = await testClient.GetRequest(endpoint);

            endpoint = "test/authfilterformalcarer";
            HttpResponseMessage informalCarerResponse = await testClient.GetRequest(endpoint);

            endpoint = "test/authfilteradmin";
            HttpResponseMessage adminResponse = await testClient.GetRequest(endpoint);

            endpoint = "test/authfilterunknown";
            HttpResponseMessage unknownResponse = await testClient.GetRequest(endpoint);

            // assert
            Assert.Equal(HttpStatusCode.Unauthorized, patientResponse.StatusCode);
            Assert.Equal(HttpStatusCode.Unauthorized, formalCarerResponse.StatusCode);
            Assert.Equal(HttpStatusCode.OK, informalCarerResponse.StatusCode);
            Assert.Equal(HttpStatusCode.Unauthorized, adminResponse.StatusCode);
            Assert.Equal(HttpStatusCode.OK, unknownResponse.StatusCode);
        }
コード例 #6
0
        public async Task PostPatientMessageOkRequest()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "message/post/?id=testpatient";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.OK;
            PatientMessage       patientMessage     = new PatientMessage();

            patientMessage.Title   = "test title";
            patientMessage.Message = "test message";
            string requestBody = JsonConvert.SerializeObject(patientMessage);

            testClient.AddHeader("ApiKey", "testcarer");
            const string expectedResponseBody = "Message sent successfully.";

            // act
            HttpResponseMessage response = await testClient.PostRequest(endpoint, body : requestBody);

            HttpStatusCode actualStatusCode   = response.StatusCode;
            string         actualResponseBody = await response.Content.ReadAsStringAsync();

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponseBody, actualResponseBody);
        }
コード例 #7
0
        public async Task PostCalendarUnauthorised()
        {
            // arrange
            TestClient   testClient  = new TestClient();
            const string endpoint    = "calendar/post/?id=testpatient";
            string       requestBody = JsonConvert.SerializeObject(new CalendarEntry()
            {
                Start = DateTime.Now.AddDays(1), End = DateTime.Now.AddDays(2)
            });
            const HttpStatusCode expectedStatusCode = HttpStatusCode.Unauthorized;
            const string         expectedResponse   = "You are not assigned to this patient.";

            testClient.AddHeader("ApiKey", "testcarer_nopatients");

            // act
            HttpResponseMessage response = await testClient.PostRequest(endpoint, body : requestBody);

            string actualResponse = await response.Content.ReadAsStringAsync();

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #8
0
        public async Task StickiesGetOkRequest()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "stickies/get";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.OK;
            StickyNote           expectedSticky     = new StickyNote()
            {
                Content = "no content", Scale = 0.5f, PatientId = "testpatient"
            };

            testClient.AddHeader("ApiKey", "testpatient");

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            HttpStatusCode actualStatusCode   = response.StatusCode;
            string         actualResponseBody = await response.Content.ReadAsStringAsync();

            ICollection <StickyNote> actualStickies = JsonConvert.DeserializeObject <ICollection <StickyNote> >(actualResponseBody);

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedSticky.Content, actualStickies.ToList()[0].Content);
            Assert.Equal(expectedSticky.Scale, actualStickies.ToList()[0].Scale);
            Assert.Equal(expectedSticky.PatientId, actualStickies.ToList()[0].PatientId);
        }
コード例 #9
0
ファイル: LogginMiddleware.cs プロジェクト: crkaz/iris-server
        public async Task LogsAddedSuccessfully()
        {
            // arrange
            TestClient   testClient    = new TestClient();
            int          expectedNLogs = new Random().Next(2, 6); // 2, 3, 4, 5
            const string endpoint      = "test/nlogs";

            testClient.AddHeader("ApiKey", "testcarer_admin");
            int initialLogCount = 0;
            int actualLogCount  = 0;

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            string responseBody = await response.Content.ReadAsStringAsync();

            initialLogCount = int.Parse(responseBody);

            for (int i = 0; i < expectedNLogs; ++i)
            {
                response = await testClient.GetRequest(endpoint);

                responseBody = await response.Content.ReadAsStringAsync();
            }
            actualLogCount = int.Parse(responseBody);

            // assert
            if (initialLogCount + expectedNLogs != actualLogCount)
            {
                throw new Exception("This test may need to be run individually to pass if tests are running in parallel.");
            }
            Assert.Equal(initialLogCount + expectedNLogs, actualLogCount);
        }
コード例 #10
0
        public async Task GetPatientsOkRequest_Multiple()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "patient/list/?id=testpatient&id=testpatient2";
            const string         expectedPatientId1 = "testpatient";
            const string         expectedPatientId2 = "testpatient2";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.OK;

            testClient.AddHeader("ApiKey", "testcarer");

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            string responseContentJson = await response.Content.ReadAsStringAsync();

            Patient[]      patients         = JsonConvert.DeserializeObject <Patient[]>(responseContentJson);
            string         actualPatientId1 = patients[0].Id;
            string         actualPatientId2 = patients[1].Id;
            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.True(patients.Length == 2);
            Assert.Equal(expectedPatientId1, actualPatientId1);
            Assert.Equal(expectedPatientId2, actualPatientId2);
        }
コード例 #11
0
        public async Task PostActivityLogsOkRequest()
        {
            // arrange
            TestClient   testClient  = new TestClient();
            const string endpoint    = "patient/logs/";
            string       requestBody = JsonConvert.SerializeObject(new ActivityLog()
            {
                Caption = "test", Location = "test", JsonDescription = "test"
            });
            const string         expectedResponse   = "Logged successfully.";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.OK;

            testClient.AddHeader("ApiKey", "testpatient");

            // act
            HttpResponseMessage response = await testClient.PostRequest(endpoint, body : requestBody);

            string actualResponse = await response.Content.ReadAsStringAsync();

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #12
0
        public async Task AllocateNotFound_Patient()
        {
            // arrange
            TestClient   testClient  = new TestClient();
            const string endpoint    = "carer/allocate/?id=testpatient";
            string       requestBody = JsonConvert.SerializeObject(new Dictionary <string, object>()
            {
                { "patient", "thisdoesntexist" }, { "carer", "testcarer" }, { "assign", false }
            });
            const HttpStatusCode expectedStatusCode = HttpStatusCode.NotFound;
            const string         expectedResponse   = "Either the patient or carer does not exist.";

            testClient.AddHeader("ApiKey", "testcarer");

            // act
            HttpResponseMessage response = await testClient.PutRequest(endpoint, body : requestBody);

            string actualResponse = await response.Content.ReadAsStringAsync();

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #13
0
        public async Task GetPatientMessageOkRequest()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "message/get/?id=testpatient";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.OK;

            testClient.AddHeader("ApiKey", "testpatient");

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            HttpStatusCode actualStatusCode = response.StatusCode;
            string         responseBody     = await response.Content.ReadAsStringAsync();

            IList <PatientMessage> actualPatientMessages = JsonConvert.DeserializeObject <IList <PatientMessage> >(responseBody);
            bool allMessagesAreUnread = true;

            foreach (var msg in actualPatientMessages)
            {
                if (msg.Read != null)
                {
                    allMessagesAreUnread = false;
                    break;
                }
            }

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.True(allMessagesAreUnread);
        }
コード例 #14
0
        public async Task AllocateBadRequest_Informal()
        {
            // arrange
            TestClient   testClient  = new TestClient();
            const string endpoint    = "carer/allocate/?id=testpatient";
            string       requestBody = JsonConvert.SerializeObject(new Dictionary <string, object>()
            {
                { "patient", "testpatient" }, { "carer", "testcarer_informal2" }, { "assign", true }
            });
            const HttpStatusCode expectedStatusCode = HttpStatusCode.BadRequest;
            const string         expectedResponse   = "Informal carers may only have a single assigned patient.";

            testClient.AddHeader("ApiKey", "testcarer");

            // act
            HttpResponseMessage response = await testClient.PutRequest(endpoint, body : requestBody);

            string actualResponse = await response.Content.ReadAsStringAsync();

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #15
0
        public async Task RoleNotFound_Carer()
        {
            // arrange
            TestClient   testClient  = new TestClient();
            const string endpoint    = "carer/role";
            string       requestBody = JsonConvert.SerializeObject(new Dictionary <string, object>()
            {
                { "carer", "doesnotexist" }, { "role", "admin" }
            });
            const HttpStatusCode expectedStatusCode = HttpStatusCode.NotFound;
            const string         expectedResponse   = "Carer does not exist.";

            testClient.AddHeader("ApiKey", "testcarer");

            // act
            HttpResponseMessage response = await testClient.PutRequest(endpoint, body : requestBody);

            string actualResponse = await response.Content.ReadAsStringAsync();

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #16
0
        public async Task GetActivityLogsOkRequest_HasLogs()
        {
            // arrange
            TestClient    testClient     = new TestClient();
            const string  endpoint       = "patient/logs/?id=testpatient&page=1&nitems=5";
            const int     expectedNLogs  = 2;
            List <string> expectedLogIds = new List <string>()
            {
                "testlog1", "testlog2"
            };
            const HttpStatusCode expectedStatusCode = HttpStatusCode.OK;

            testClient.AddHeader("ApiKey", "testcarer");
            List <string> actualLogIds = new List <string>();

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            string responseContentJson = await response.Content.ReadAsStringAsync();

            ActivityLog[]  logs             = JsonConvert.DeserializeObject <ActivityLog[]>(responseContentJson);
            int            actualNLogs      = logs.Length;
            HttpStatusCode actualStatusCode = response.StatusCode;

            foreach (ActivityLog a in logs)
            {
                actualLogIds.Add(a.Id);
            }

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.True(actualNLogs >= expectedNLogs);
        }
コード例 #17
0
        public async Task StickiesPostOkRequest()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "stickies/post";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.OK;
            StickyNote           sticky             = new StickyNote()
            {
                Content = "no content", Scale = 0.5f, PatientId = "testpatient"
            };
            const string expectedResponse = "Successfully added sticky note.";
            string       requestBody      = JsonConvert.SerializeObject(new Dictionary <string, object>()
            {
                { "content", "no content" }, { "scale", 0.5f }
            });

            testClient.AddHeader("ApiKey", "testpatient");

            // act
            HttpResponseMessage response = await testClient.PostRequest(endpoint, body : requestBody);

            HttpStatusCode actualStatusCode = response.StatusCode;
            string         actualResponse   = await response.Content.ReadAsStringAsync();

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #18
0
        public async Task DeletePatientsOkRequest()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "patient/delete/?id=testpatient";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.OK;

            testClient.AddHeader("ApiKey", "testcarer");

            // act
            HttpResponseMessage response = await testClient.DeleteRequest(endpoint);

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
        }
コード例 #19
0
        public async Task GetPatientsBadRequest_NoPatient()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "patient/list/?id=doesnotexist123";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.Unauthorized;

            testClient.AddHeader("ApiKey", "testcarer");

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
        }
コード例 #20
0
        public async Task GetActivityLogsUnauthorised()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "patient/logs/?id=testpatient&page=1&nitems=5";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.Unauthorized;

            testClient.AddHeader("ApiKey", "testcarer_nopatients");

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            string responseContentJson = await response.Content.ReadAsStringAsync();

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
        }
コード例 #21
0
        public async Task UpdatePatientStatusBadRequest_InvalidStatus()
        {
            // arrange
            TestClient           testClient           = new TestClient();
            const string         endpoint             = "patient/updatestatus/?status=AnInvalidStatus";
            const HttpStatusCode expectedStatusCode   = HttpStatusCode.BadRequest;
            const string         expectedResponseBody = "Invalid status argument.";

            testClient.AddHeader("ApiKey", "testpatient");

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            HttpStatusCode actualStatusCode   = response.StatusCode;
            string         actualResponseBody = await response.Content.ReadAsStringAsync();

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponseBody, actualResponseBody);
        }
コード例 #22
0
        public async Task StickiesGetNotFound()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "stickies/get";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.NotFound;
            const string         expectedResponse   = "Patient has no sticky notes.";

            testClient.AddHeader("ApiKey", "testpatient2");

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            HttpStatusCode actualStatusCode = response.StatusCode;
            string         actualResponse   = await response.Content.ReadAsStringAsync();

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #23
0
        public async Task StickiesDeleteUnauthorised()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "stickies/delete/?id=dasdaoi";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.Unauthorized;
            const string         expectedResponse   = "Patient does not own that sticky note.";

            testClient.AddHeader("ApiKey", "testpatient");

            // act
            HttpResponseMessage response = await testClient.DeleteRequest(endpoint);

            HttpStatusCode actualStatusCode = response.StatusCode;
            string         actualResponse   = await response.Content.ReadAsStringAsync();

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #24
0
        public async Task StickiesDeleteOkRequest()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "stickies/delete/?id=testpatient";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.OK;
            const string         expectedResponse   = "Sticky note deleted successfully.";

            testClient.AddHeader("ApiKey", "testpatient");

            // act
            HttpResponseMessage response = await testClient.DeleteRequest(endpoint);

            HttpStatusCode actualStatusCode = response.StatusCode;
            string         actualResponse   = await response.Content.ReadAsStringAsync();

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #25
0
        public async Task GetPatientsUnauthorised()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "patient/list/?id=testpatient";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.Unauthorized;

            testClient.AddHeader("ApiKey", "testcarer_nopatients");
            const string expectedResponseBody = "You are not assigned to all of the specified patients.";

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            HttpStatusCode actualStatusCode   = response.StatusCode;
            string         actualResponseBody = await response.Content.ReadAsStringAsync();

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponseBody, actualResponseBody);
        }
コード例 #26
0
        public async Task DeleteCarerUnauthorised()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "carer/delete/?id=testcarer";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.Unauthorized;
            const string         expectedResponse   = "Accounts must be deleted by an admin other than yourself.";

            testClient.AddHeader("ApiKey", "testcarer");

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            string actualResponse = await response.Content.ReadAsStringAsync();

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #27
0
        public async Task GetPatientsNotFound()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "carer/patients";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.NotFound;
            const string         expectedResponse   = "This carer does not have any patients assigned.";

            testClient.AddHeader("ApiKey", "testcarer_nopatients");

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            string actualResponse = await response.Content.ReadAsStringAsync();

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #28
0
        public async Task DeletePatientsNotFound_NoPatient()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "patient/delete/?id=doesnotexist123";
            const string         expectedResponse   = "Patient not found.";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.NotFound;

            testClient.AddHeader("ApiKey", "testcarer");

            // act
            HttpResponseMessage response = await testClient.DeleteRequest(endpoint);

            string actualResponse = await response.Content.ReadAsStringAsync();

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedResponse, actualResponse);
        }
コード例 #29
0
        public async Task GetCarerOkRequest()
        {
            // arrange
            TestClient           testClient         = new TestClient();
            const string         endpoint           = "carer/get";
            const HttpStatusCode expectedStatusCode = HttpStatusCode.OK;

            testClient.AddHeader("ApiKey", "testcarer");

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            string responseBody = await response.Content.ReadAsStringAsync();

            ICollection <Carer> carers           = JsonConvert.DeserializeObject <ICollection <Carer> >(responseBody);
            HttpStatusCode      actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.True(carers.Count > 1);
        }
コード例 #30
0
        public async Task UpdatePatientStatusOkRequest()
        {
            // arrange
            TestClient           testClient            = new TestClient();
            const string         endpoint              = "patient/updatestatus/?status=offline";
            string               expectedPatientStatus = Patient.PatientStatus.offline.ToString();
            const HttpStatusCode expectedStatusCode    = HttpStatusCode.OK;

            testClient.AddHeader("ApiKey", "testpatient");

            // act
            HttpResponseMessage response = await testClient.GetRequest(endpoint);

            string actualPatientStatus = await response.Content.ReadAsStringAsync();

            HttpStatusCode actualStatusCode = response.StatusCode;

            // assert
            Assert.Equal(expectedStatusCode, actualStatusCode);
            Assert.Equal(expectedPatientStatus, actualPatientStatus);
        }