Пример #1
0
        public void MessageControllerCreateTest()
        {
            var controller = new MessageController();
            var result     = controller.Create() as ViewResult;

            Assert.AreEqual("", result.ViewName);
        }
Пример #2
0
        public async void Create_Errors()
        {
            MessageControllerMockFacade mock = new MessageControllerMockFacade();

            var mockResponse = new Mock <CreateResponse <ApiMessageServerResponseModel> >(null as ApiMessageServerResponseModel);
            var mockRecord   = new ApiMessageServerResponseModel();

            mockResponse.SetupGet(x => x.Success).Returns(false);

            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiMessageServerRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiMessageServerResponseModel> >(mockResponse.Object));
            MessageController controller = new MessageController(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.Create(new ApiMessageServerRequestModel());

            response.Should().BeOfType <ObjectResult>();
            (response as ObjectResult).StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity);
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiMessageServerRequestModel>()));
        }
Пример #3
0
        public async void Create_No_Errors()
        {
            MessageControllerMockFacade mock = new MessageControllerMockFacade();

            var mockResponse = ValidationResponseFactory <ApiMessageServerResponseModel> .CreateResponse(null as ApiMessageServerResponseModel);

            mockResponse.SetRecord(new ApiMessageServerResponseModel());
            mock.ServiceMock.Setup(x => x.Create(It.IsAny <ApiMessageServerRequestModel>())).Returns(Task.FromResult <CreateResponse <ApiMessageServerResponseModel> >(mockResponse));
            MessageController controller = new MessageController(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.Create(new ApiMessageServerRequestModel());

            response.Should().BeOfType <CreatedResult>();
            (response as CreatedResult).StatusCode.Should().Be((int)HttpStatusCode.Created);
            var createResponse = (response as CreatedResult).Value as CreateResponse <ApiMessageServerResponseModel>;

            createResponse.Record.Should().NotBeNull();
            mock.ServiceMock.Verify(x => x.Create(It.IsAny <ApiMessageServerRequestModel>()));
        }