Ejemplo n.º 1
0
        public void DeleteCourse_ShouldReturnOK()
        {
            var context = new TestCourseContext();
            var item = GetDemoCourse();
            context.Courses.Add(item);

            var controller = new CoursesController(context);

            var deleteResult = controller.DeleteCourse(3);
            var result = deleteResult.Result as OkNegotiatedContentResult<Course>;

            Assert.IsNotNull(result);
            Assert.AreEqual(item.Id, result.Content.Id);
        }
Ejemplo n.º 2
0
        public void DeleteCourse_ShouldReturnNotFound_WhenInvalidId()
        {
            var context = new TestCourseContext();
            var item = GetDemoCourse();
            context.Courses.Add(item);

            var controller = new CoursesController(context);

            var deleteResult = controller.DeleteCourse(999);
            var result = deleteResult.Result as NotFoundResult;

            Assert.IsNotNull(result);
            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }