public void GetCourse_Test()
        {
            var Respond = _courseController.GetCourse(2);
            var Result  = Respond as OkObjectResult;

            Assert.AreEqual(200, Result.StatusCode);
        }
Exemplo n.º 2
0
        public void GetCourse_ShouldNotFindCourse()
        {
            var controller = new CourseController(_inMemoryRep);

            var result = controller.GetCourse(999);

            Assert.IsInstanceOfType(result, typeof(NotFoundResult));
        }
Exemplo n.º 3
0
        public void GetCourse_ShouldReturnCorrectCourse()
        {
            var testCourses = _inMemoryRep.GetAll() as List <Course>;
            var controller  = new CourseController(_inMemoryRep);

            var result = controller.GetCourse(4) as OkNegotiatedContentResult <Course>;

            Assert.IsNotNull(result);
            Assert.AreEqual(testCourses[3].Title, result.Content.Title);
        }
        public void GetReturnsNotFound_Moq()
        {
            // Arrange
            var mockRepository = new Mock <ICourseRepository>();
            var controller     = new CourseController(mockRepository.Object);

            // Act
            IHttpActionResult actionResult = controller.GetCourse(10);

            // Assert
            Assert.IsInstanceOfType(actionResult, typeof(NotFoundResult));
        }
        public void GetReturnsCourseWithSameId_Moq()
        {
            // Arrange
            var mockRepository = new Mock <ICourseRepository>();

            mockRepository.Setup(x => x.GetByID(11))
            .Returns(new Course {
                Id = 11
            });

            var controller = new CourseController(mockRepository.Object);

            // Act
            IHttpActionResult actionResult = controller.GetCourse(11);
            var contentResult = actionResult as OkNegotiatedContentResult <Course>;

            // Assert
            Assert.IsNotNull(contentResult);
            Assert.IsNotNull(contentResult.Content);
            Assert.AreEqual(11, contentResult.Content.Id);
        }
Exemplo n.º 6
0
        public override Task <CourseReply> GetCourse(CourseIdRequest request, ServerCallContext context)
        {
            Course course = logic.GetCourse(request.CourseID);

            return(Task.FromResult <CourseReply>(FromPoco(course)));
        }