public void InstructorApiController_InstructorIdExists_ReturnOK()
        {
            //Arrange
            Instructor        instructor = generator.CreateInstructor("John", "Doe", "Doe", "Doe");
            IHttpActionResult result     = controllerToTest.Get(instructor.ID);

            //Assert
            Assert.That(result, Is.Not.Null);
            Assert.IsInstanceOf(typeof(OkNegotiatedContentResult <InstructorDTO>), result);

            OkNegotiatedContentResult <InstructorDTO> instructor_result = result as OkNegotiatedContentResult <InstructorDTO>;

            Assert.AreEqual(instructor_result.Content.instructorId, instructor.ID);
        }
Exemple #2
0
        public void Call_Instructor_Api_With_BadID_Send_Error_Message()
        {
            #region Arrange
            Dictionary <string, string> json = new Dictionary <string, string>();
            json["Status"]  = "Error";
            json["Message"] = "There is no instructor with that Id";
            var awaited_response = JsonConvert.SerializeObject(json);
            #endregion

            #region Act
            var api_response  = controllerToTest.Get(999999);
            var response      = api_response as OkNegotiatedContentResult <Dictionary <string, string> >;
            var json_response = JsonConvert.SerializeObject(response.Content);
            #endregion


            #region assert
            Assert.That(api_response.GetType() == typeof(OkNegotiatedContentResult <Dictionary <string, string> >));
            Assert.That(json_response == awaited_response);
            #endregion
        }