Пример #1
0
        public void it_should_return_data_for_get()
        {
            // Arrange
            LessonController controller = new LessonController();
            // Act
            var result = controller.Get().Result;

            // Assert
            Assert.IsNotNull(result);
        }
Пример #2
0
        public async void Get_Not_Exists()
        {
            LessonControllerMockFacade mock = new LessonControllerMockFacade();

            mock.ServiceMock.Setup(x => x.Get(It.IsAny <int>())).Returns(Task.FromResult <ApiLessonResponseModel>(null));
            LessonController controller = new LessonController(mock.ApiSettingsMoc.Object, mock.LoggerMock.Object, mock.TransactionCoordinatorMock.Object, mock.ServiceMock.Object, mock.ModelMapperMock.Object);

            controller.ControllerContext             = new ControllerContext();
            controller.ControllerContext.HttpContext = new DefaultHttpContext();

            IActionResult response = await controller.Get(default(int));

            response.Should().BeOfType <StatusCodeResult>();
            (response as StatusCodeResult).StatusCode.Should().Be((int)HttpStatusCode.NotFound);
            mock.ServiceMock.Verify(x => x.Get(It.IsAny <int>()));
        }