Beispiel #1
0
        public void PutBySource_CanModifyService()
        {
            // Arrange
            var sourdeId = "sourceId";

            serviceServiceMockSetup.Setup(s => s.GetServiceBySource(sourdeId))
            .Returns(new VmOpenApiServiceVersionBase()
            {
                PublishingStatus = PublishingStatus.Published.ToString(), Security = new VmSecurityOwnOrganization {
                    IsOwnOrganization = true
                }
            });
            serviceServiceMockSetup.Setup(s => s.SaveService(It.IsAny <VmOpenApiServiceInVersionBase>(), It.IsAny <bool>(), defaultVersion, false, sourdeId))
            .Returns(new V7VmOpenApiService());
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoServiceMock.Object, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

            // Act
            var result = controller.PutBySource(sourdeId, new V7VmOpenApiServiceInBase(), false);

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

            Assert.IsType <V7VmOpenApiService>(okResult.Value);
        }
Beispiel #2
0
        public void GetByMunicipality_ModelIsNull()
        {
            // Arrange
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoService, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

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

            // Assert
            result.Should().BeOfType <NotFoundObjectResult>();
        }
Beispiel #3
0
        [InlineData("00000000-0000-0000-0000-000000000000")] // empty Guid
        public void Get_IdNotValid(string id)
        {
            // Arrange
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoService, serviceAndChannelService, channelService, userService, logger);

            // Act
            Action act = () => controller.Get(id);

            // Assert
            act.ShouldThrow <Exception>();
        }
Beispiel #4
0
        public void GetByServiceChannel_ChannelNotExists()
        {
            // Arrange
            channelServiceMockSetup.Setup(s => s.ChannelExists(id)).Returns(false);
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoService, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

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

            // Assert
            result.Should().BeOfType <NotFoundObjectResult>();
        }
Beispiel #5
0
        public void GetActive_ServiceNotExists()
        {
            // Arrange
            serviceServiceMockSetup.Setup(s => s.GetServiceById(It.IsAny <Guid>(), defaultVersion, It.IsAny <VersionStatusEnum>())).Returns((VmOpenApiServiceVersionBase)null);
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoService, serviceAndChannelService, channelService, userService, logger);

            // Act
            var result = controller.GetActive(strId);

            // Assert
            result.Should().BeOfType <NotFoundObjectResult>();
        }
Beispiel #6
0
        public void GetByMunicipality_MunicipalityNotExists()
        {
            // Arrange
            codeServiceMockSetup.Setup(s => s.GetMunicipalityByCode(It.IsAny <string>(), It.IsAny <bool>())).Returns((VmListItem)null);
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoService, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

            // Act
            var result = controller.GetByMunicipality("code", null);

            // Assert
            result.Should().BeOfType <NotFoundObjectResult>();
        }
Beispiel #7
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>();
        }
Beispiel #8
0
        public void PutBySource_SourceIdNotValid(string sourceId)
        {
            // Arrange
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoServiceMock.Object, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

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

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

            Assert.IsType <VmError>(notFoundResult.Value);
        }
Beispiel #9
0
        public void PutBySource_RequestIsNull()
        {
            // Arrange
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoServiceMock.Object, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

            // Act
            var result = controller.PutBySource("sourceId", null, false);

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

            Assert.IsType <SerializableError>(badResult.Value);
        }
Beispiel #10
0
        public void GetByServiceClass_ClassNotExists()
        {
            var uri = "invalid_uri";

            fintoServiceMock.Setup(s => s.GetServiceClassByUri(uri)).Returns((VmOpenApiFintoItemVersionBase)null);
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoServiceMock.Object, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

            // Act
            var result = controller.GetByServiceClass(uri, null, pageNumber);

            // Assert
            result.Should().BeOfType <NotFoundObjectResult>();
        }
Beispiel #11
0
        public void Put_CurrentVersionNotFound()
        {
            // Arrange
            serviceServiceMockSetup.Setup(s => s.GetServiceByIdSimple(id, false)).Returns((VmOpenApiServiceVersionBase)null);
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoServiceMock.Object, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

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

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

            Assert.IsType <VmError>(notFoundResult.Value);
        }
Beispiel #12
0
        public void GetActive_ServiceExists()
        {
            // Arrange
            serviceServiceMockSetup.Setup(s => s.GetServiceById(It.IsAny <Guid>(), defaultVersion, It.IsAny <VersionStatusEnum>())).Returns(new VmOpenApiServiceVersionBase());
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoService, serviceAndChannelService, channelService, userService, logger);

            // Act
            var result = controller.GetActive(strId);

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

            Assert.IsAssignableFrom <VmOpenApiServiceVersionBase>(okResult.Value);
        }
Beispiel #13
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);
        }
Beispiel #14
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);
        }
Beispiel #15
0
        public void Get_Services_CanCall()
        {
            // Arrange
            serviceServiceMockSetup.Setup(s => s.GetServices(null, pageNumber, It.IsAny <int>(), It.IsAny <bool>(), It.IsAny <bool>()))
            .Returns(new V3VmOpenApiGuidPage(pageNumber, pageSize));
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoService, serviceAndChannelService, channelService, userService, logger);

            // Act
            var result = controller.Get(null, pageNumber);

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(result);
            var model    = Assert.IsAssignableFrom <V3VmOpenApiGuidPage>(okResult.Value);

            Assert.Equal(pageNumber, model.PageNumber);
        }
Beispiel #16
0
        public void GetByServiceChannel_ChannelExists()
        {
            // Arrange
            channelServiceMockSetup.Setup(s => s.ChannelExists(id)).Returns(true);
            serviceServiceMockSetup.Setup(s => s.GetServicesByServiceChannel(id, null, pageNumber, pageSize))
            .Returns(new V3VmOpenApiGuidPage(pageNumber, pageSize));
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoService, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

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

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(result);
            var model    = Assert.IsAssignableFrom <V3VmOpenApiGuidPage>(okResult.Value);

            Assert.Equal(pageNumber, model.PageNumber);
        }
Beispiel #17
0
        public void GetByMunicipality_MunicipalityExists()
        {
            // Arrange
            var municipalityId = Guid.NewGuid();

            codeServiceMockSetup.Setup(s => s.GetMunicipalityByCode(It.IsAny <string>(), It.IsAny <bool>())).Returns(new VmListItem {
                Id = municipalityId
            });
            var page = 1; var pageSize = 10;

            serviceServiceMockSetup.Setup(s => s.GetServicesByMunicipality(municipalityId, null, page, pageSize)).Returns(new VmOpenApiEntityGuidPage(page, pageSize));
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoService, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

            // Act
            var result = controller.GetByMunicipality(municipalityId.ToString(), null, page);

            // Assert
            result.Should().BeOfType <OkObjectResult>();
        }
Beispiel #18
0
        public void GetByServiceClass_ClassExists()
        {
            var uri = "invalid_uri";

            fintoServiceMock.Setup(s => s.GetServiceClassByUri(uri)).Returns(new VmOpenApiFintoItemVersionBase()
            {
                Id = id
            });
            serviceServiceMockSetup.Setup(s => s.GetServicesByServiceClass(id, null, pageNumber, pageSize))
            .Returns(new V3VmOpenApiGuidPage(pageNumber, pageSize));
            var controller = new V7ServiceController(serviceServiceMockSetup.Object, commonService, codeService, settings, gdService,
                                                     fintoServiceMock.Object, serviceAndChannelService, channelServiceMockSetup.Object, userService, logger);

            // Act
            var result = controller.GetByServiceClass(uri, null, pageNumber);

            // Assert
            var okResult = Assert.IsType <OkObjectResult>(result);
            var model    = Assert.IsAssignableFrom <V3VmOpenApiGuidPage>(okResult.Value);

            Assert.Equal(pageNumber, model.PageNumber);
        }