Exemplo n.º 1
0
        public void PutBySource_SourceIdNotValid(string sourceId)
        {
            // Arrange
            var controller = new V7OrganizationController(organizationServiceMockSetup.Object, codeService, settings, logger, commonService, userService);

            // Act
            var result = controller.PutBySource(sourceId, new V7VmOpenApiOrganizationInBase());

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

            Assert.IsType <VmError>(notFoundResult.Value);
        }
Exemplo n.º 2
0
        public void PutBySource_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.PutBySource("sourceId", null);

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

            Assert.IsType <SerializableError>(badResult.Value);
        }
Exemplo n.º 3
0
        public void PutBySource_SourceIdNotFound()
        {
            // Arrange
            var sourdeId = "sourceId";

            commonServiceMockSetup.Setup(s => s.OrganizationExists(It.IsAny <Guid>(), null)).Returns(true);
            organizationServiceMockSetup.Setup(s => s.GetOrganizationBySource(sourdeId, 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)).Throws <Exception>();
            var controller = new V7OrganizationController(organizationServiceMockSetup.Object, codeService, settings, logger, commonService, userService);

            // Act
            Action act = () => controller.PutBySource(sourdeId, new V7VmOpenApiOrganizationInBase());

            // Assert
            act.ShouldThrow <Exception>();
        }
Exemplo n.º 4
0
        public void PutBySource_CanModifyOrganization()
        {
            // Arrange
            var sourdeId = "sourceId";

            commonServiceMockSetup.Setup(s => s.OrganizationExists(It.IsAny <Guid>(), null)).Returns(true);
            organizationServiceMockSetup.Setup(s => s.GetOrganizationBySource(sourdeId, 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.PutBySource(sourdeId, new V7VmOpenApiOrganizationInBase());

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

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