コード例 #1
0
        public void Post_serviceServiceThrowsException()
        {
            // Arrange
            serviceServiceMockSetup.Setup(s => s.AddService(It.IsAny <VmOpenApiServiceInVersionBase>(), false, defaultVersion, false)).Throws <Exception>();
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoServiceMock.Object, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

            // Act
            Action act = () => controller.Post(new V7VmOpenApiServiceIn(), false);

            // Assert
            act.ShouldThrow <Exception>();
        }
コード例 #2
0
        public void Post_RequestIsNull()
        {
            // Arrange
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoServiceMock.Object, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

            // Act
            var result = controller.Post(null, false);

            // Assert
            var badResult = Assert.IsType <BadRequestObjectResult>(result);

            Assert.IsType <SerializableError>(badResult.Value);
        }
コード例 #3
0
        public void Post_RequestIsValid()
        {
            // Arrange
            serviceServiceMockSetup.Setup(s => s.AddService(It.IsAny <VmOpenApiServiceInVersionBase>(), false, defaultVersion, false))
            .Returns(new V7VmOpenApiService());
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoServiceMock.Object, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

            // Act
            var result = controller.Post(new V7VmOpenApiServiceIn(), false);

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(result);

            Assert.IsType <V7VmOpenApiService>(okResult.Value);
        }
コード例 #4
0
        public void Post_RequestIsNotValid()
        {
            // Arrange
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoServiceMock.Object, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

            controller.ModelState.AddModelError("Request", "NotValid");

            // Act
            var result = controller.Post(new V7VmOpenApiServiceIn(), false);

            // Assert
            var badResult = Assert.IsType <BadRequestObjectResult>(result);

            Assert.IsType <SerializableError>(badResult.Value);
        }