Ejemplo n.º 1
0
        public async Task DeleteAlreadyDeletedPatient_ReturnsBadRequest()
        {
            var controller = new PatientsController(_context, _relationshipMock.Object);

            long id = 1;

            await controller.DeletePatient(id);

            _relationshipMock.Verify(mock => mock.DeleteDosagePatientId(id), Times.Once);

            var result = await controller.DeletePatient(id);

            //verify that DeleteDosagePatientId did not get called again 
            //for an already deleted patient
            _relationshipMock.Verify(mock => mock.DeleteDosagePatientId(id), Times.Once);

            Assert.IsAssignableFrom<BadRequestObjectResult>(result.Result);

        }
Ejemplo n.º 2
0
        public async Task PutRestoredPatient_ReturnsBadRequest()
        {
            var controller = new PatientsController(_context, _relationshipMock.Object);

            long id = 4;

            await controller.DeletePatient(id);

            Patient patient = new Patient();

            patient.Id = id;
            patient.Name = "Put Patient";
            patient.Deleted = false;           

            var result = await controller.PutPatient(id, patient);

            Assert.IsAssignableFrom<BadRequestObjectResult>(result);
        }
Ejemplo n.º 3
0
        public async Task DeletePatient_SetDeletedFlag()
        {
            var controller = new PatientsController(_context, _relationshipMock.Object);

            long id = 1;
                        
            await controller.DeletePatient(id);

            _relationshipMock.Verify(mock => mock.DeleteDosagePatientId(id), Times.Once);

            var result = await controller.GetPatient(id);

            var patientResult = Assert.IsType<Patient>(result.Value);

            Assert.Equal(id, patientResult.Id);
            Assert.True(patientResult.Deleted);
            Assert.Equal("John Smith", patientResult.Name);
        }
Ejemplo n.º 4
0
        public async Task DeletePatient()
        {
            //Arrange.
            m_patientCtrl.Request       = new HttpRequestMessage(HttpMethod.Delete, "http://localhost/api/Patients");
            m_patientCtrl.Configuration = new HttpConfiguration();

            //Get an existing Patient entity to delete.
            HttpResponseMessage responseGetPatient = m_patientCtrl.GetPatient(3);

            Patient patient = await responseGetPatient.Content.ReadAsAsync <Patient>();

            //Act.
            HttpResponseMessage responseDeletePatient = await m_patientCtrl.DeletePatient(patient.PatientID);

            //Assert.
            Assert.IsTrue(responseDeletePatient.StatusCode.Equals(HttpStatusCode.OK));

            //Confirm deletion.
            HttpResponseMessage responseDeletedPatient = m_patientCtrl.GetPatient(patient.PatientID);

            Assert.IsTrue(responseDeletedPatient.StatusCode.Equals(HttpStatusCode.NotFound));
        }