Ejemplo n.º 1
0
        public void Should_return_JSON_string_when_doctor_is_updated()
        {
            IDoctorForResponse model = null;

            try
            {
                // Given
                Browser browser = CreateBrowser();
                dynamic doctor  = CreateDoctorToBeDeleted(browser);
                model = CreateModelForUpdate(doctor);

                dynamic expected = CreatedExpectedDoctorForUpdate(model.Id);

                // When
                BrowserResponse result = browser.Put("/doctors/",
                                                     with =>
                {
                    with.JsonBody(model);
                });

                dynamic actual = XUnitDoctorsHelper.ToDynamic(result.Body.AsString());

                // Then
                XUnitDoctorsHelper.AssertDoctor(expected,
                                                actual);
            }
            finally
            {
                if (model != null)
                {
                    DeleteDoctorById(model.Id);
                }
            }
        }
Ejemplo n.º 2
0
        public void Should_update_database_when_doctor_is_updated()
        {
            IDoctorForResponse model = null;

            try
            {
                // Given
                Browser browser = CreateBrowser();
                dynamic doctor  = CreateDoctorToBeDeleted(browser);
                model = CreateModelForUpdate(doctor);

                // When
                BrowserResponse result = browser.Put("/doctors/",
                                                     with =>
                {
                    with.JsonBody(model);
                });

                // Then
                Assert.Equal(HttpStatusCode.OK,
                             result.StatusCode);

                // *** Post-conditions ***
                // Given
                dynamic expected = CreatedExpectedDoctorForUpdate(model.Id);

                // When
                result = browser.Get("/doctors/" + model.Id,
                                     with =>
                {
                    with.HttpRequest();
                });

                dynamic actual = XUnitDoctorsHelper.ToDynamic(result.Body.AsString());

                // Then
                XUnitDoctorsHelper.AssertDoctor(expected,
                                                actual);
            }
            finally
            {
                if (model != null)
                {
                    DeleteDoctorById(model.Id);
                }
            }
        }
Ejemplo n.º 3
0
        public void Should_return_JSON_string_when_doctor_with_id_exists()
        {
            // Given
            dynamic expected = CreateExpectedResponseForMiller();
            Browser browser  = CreateBrowser();

            // When
            BrowserResponse result = browser.Get("/doctors/1",
                                                 with =>
            {
                with.HttpRequest();
            });

            dynamic actual = XUnitDoctorsHelper.ToDynamic(result.Body.AsString());

            // Then
            XUnitDoctorsHelper.AssertDoctor(expected,
                                            actual);
        }
Ejemplo n.º 4
0
        public void Should_return_JSON_string_when_doctor_is_deleted()
        {
            // Given
            Browser browser  = CreateBrowser();
            dynamic doctor   = CreateDoctorToBeDeleted(browser);
            int     doctorId = Convert.ToInt32(doctor ["Id"].Value);
            dynamic expected = CreatedExpectedDoctorFor(doctorId);

            // When
            BrowserResponse result = browser.Delete("/doctors/" + doctorId,
                                                    with =>
            {
                with.HttpRequest();
            });

            dynamic actual = XUnitDoctorsHelper.ToDynamic(result.Body.AsString());

            // Then
            XUnitDoctorsHelper.AssertDoctor(expected,
                                            actual);
        }