Esempio n. 1
0
        public void Put_OrganizationIdNotValid(string organizationId)
        {
            // Arrange
            var controller = new V7OrganizationController(organizationServiceMockSetup.Object, codeService, settings, logger, commonService, userService);

            // Act
            var result = controller.Put(organizationId, new V7VmOpenApiOrganizationInBase());

            // Assert
            var notFoundResult = Assert.IsType <NotFoundObjectResult>(result);

            Assert.IsType <VmError>(notFoundResult.Value);
        }
Esempio n. 2
0
        public void Put_OrganizationNotExists()
        {
            // Arrange
            commonServiceMockSetup.Setup(s => s.OrganizationExists(It.IsAny <Guid>(), null)).Returns(false);
            var controller = new V7OrganizationController(organizationServiceMockSetup.Object, codeService, settings, logger, commonService, userService);

            // Act
            var result = controller.Put(strId, new V7VmOpenApiOrganizationInBase());

            // Assert
            var notFoundResult = Assert.IsType <NotFoundObjectResult>(result);

            Assert.IsType <VmError>(notFoundResult.Value);
        }
Esempio n. 3
0
        public void Put_RequestIsNull()
        {
            // Arrange
            commonServiceMockSetup.Setup(s => s.OrganizationExists(It.IsAny <Guid>(), null)).Returns(true);
            var controller = new V7OrganizationController(organizationServiceMockSetup.Object, codeService, settings, logger, commonService, userService);

            // Act
            var result = controller.Put(strId, null);

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

            Assert.IsType <SerializableError>(badResult.Value);
        }
Esempio n. 4
0
        public void Put_CurrentVersionNotFound()
        {
            // Arrange
            commonServiceMockSetup.Setup(s => s.OrganizationExists(It.IsAny <Guid>(), null)).Returns(true);
            organizationServiceMockSetup.Setup(s => s.GetOrganizationById(It.IsAny <Guid>(), It.IsAny <int>(), It.IsAny <bool>())).Returns((VmOpenApiOrganizationVersionBase)null);
            var controller = new V7OrganizationController(organizationServiceMockSetup.Object, codeService, settings, logger, commonService, userService);

            // Act
            var result = controller.Put(strId, new V7VmOpenApiOrganizationInBase());

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

            Assert.IsType <SerializableError>(badResult.Value);
        }
Esempio n. 5
0
        public void Put_CanModifyOrganization()
        {
            // Arrange
            commonServiceMockSetup.Setup(s => s.OrganizationExists(It.IsAny <Guid>(), null)).Returns(true);
            organizationServiceMockSetup.Setup(s => s.GetOrganizationById(It.IsAny <Guid>(), It.IsAny <int>(), It.IsAny <bool>())).Returns(new VmOpenApiOrganizationVersionBase {
                PublishingStatus = PublishingStatus.Published.ToString()
            });
            organizationServiceMockSetup.Setup(s => s.SaveOrganization(It.IsAny <VmOpenApiOrganizationInVersionBase>(), It.IsAny <bool>(), defaultVersion)).Returns(new V7VmOpenApiOrganization());
            var controller = new V7OrganizationController(organizationServiceMockSetup.Object, codeService, settings, logger, commonService, userService);

            // Act
            var result = controller.Put(strId, new V7VmOpenApiOrganizationInBase());

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

            Assert.IsType <V7VmOpenApiOrganization>(okResult.Value);
        }