public void AddressTypeIsLocation_SeveralForeigAddressesIncluded_NotValid(string type)
        {
            // Arrange & act
            var vm = new VmOpenApiServiceLocationChannelInVersionBase()
            {
                Addresses = new List <V7VmOpenApiAddressWithMovingIn>
                {
                    new V7VmOpenApiAddressWithMovingIn
                    {
                        Type    = type,
                        SubType = AddressConsts.ABROAD
                    },
                    new V7VmOpenApiAddressWithMovingIn
                    {
                        Type    = type,
                        SubType = AddressConsts.ABROAD
                    },
                }
            };
            var validator = new ServiceLocationChannelValidator(vm, commonService, codeService, serviceService);

            // Act
            validator.Validate(controller.ModelState);

            // Assert
            controller.ModelState.IsValid.Should().BeFalse();
        }
        public void AddressTypeIsLocation_2SIngleSubTypesIncluded_Valid()
        {
            // Arrange & act
            var vm = new VmOpenApiServiceLocationChannelInVersionBase()
            {
                Addresses = new List <V7VmOpenApiAddressWithMovingIn>
                {
                    new V7VmOpenApiAddressWithMovingIn
                    {
                        Type    = AddressConsts.LOCATION,
                        SubType = AddressConsts.SINGLE
                    },
                    new V7VmOpenApiAddressWithMovingIn
                    {
                        Type    = AddressConsts.LOCATION,
                        SubType = AddressConsts.SINGLE
                    },
                }
            };
            var validator = new ServiceLocationChannelValidator(vm, commonService, codeService, serviceService);


            // Act
            validator.Validate(controller.ModelState);

            // Assert
            controller.ModelState.IsValid.Should().BeTrue();
        }
        /// <summary>
        /// Puts the service location channel by source.
        /// </summary>
        /// <param name="sourceId">The source identifier.</param>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        protected IActionResult PutServiceLocationChannelBySource(string sourceId, IVmOpenApiServiceLocationChannelInVersionBase request)
        {
            if (request == null)
            {
                ModelState.AddModelError("RequestIsNull", CoreMessages.OpenApi.RequestIsNull);
                return(new BadRequestObjectResult(ModelState));
            }
            var vmBase    = request.VersionBase() as VmOpenApiServiceLocationChannelInVersionBase;
            var validator = new ServiceLocationChannelValidator(vmBase, commonService, codeService, serviceService);

            return(PutServiceChannel(vmBase, validator, "Service location", sourceId: sourceId));
        }
        /// <summary>
        /// Posts the service location channel.
        /// </summary>
        /// <param name="request">The request.</param>
        /// <returns></returns>
        protected IActionResult PostServiceLocationChannel(IVmOpenApiServiceLocationChannelInVersionBase request)
        {
            if (request == null)
            {
                ModelState.AddModelError("RequestIsNull", CoreMessages.OpenApi.RequestIsNull);
                return(new BadRequestObjectResult(ModelState));
            }

            // Validate the items
            if (!ModelState.IsValid)
            {
                return(new BadRequestObjectResult(ModelState));
            }

            var vmBase    = request.VersionBase() as VmOpenApiServiceLocationChannelInVersionBase;
            var validator = new ServiceLocationChannelValidator(vmBase, commonService, codeService, serviceService);

            return(PostServiceChannel(vmBase, validator));
        }
        [InlineData(AddressConsts.POSTOFFICEBOX)] // not allowed
        public void AddressTypeIsLocation_SubTypeNotValid(string subType)
        {
            // Arrange & act
            var vm = new VmOpenApiServiceLocationChannelInVersionBase()
            {
                Addresses = new List <V7VmOpenApiAddressWithMovingIn>
                {
                    new V7VmOpenApiAddressWithMovingIn
                    {
                        Type    = AddressConsts.LOCATION,
                        SubType = subType
                    }
                }
            };
            var validator = new ServiceLocationChannelValidator(vm, commonService, codeService, serviceService);


            // Act
            validator.Validate(controller.ModelState);

            // Assert
            controller.ModelState.IsValid.Should().BeFalse();
        }
        [InlineData(AddressConsts.ABROAD)]        // allowed
        public void AddressTypeIsPostal_SubTypeValid(string subType)
        {
            // Arrange & act
            var vm = new VmOpenApiServiceLocationChannelInVersionBase()
            {
                Addresses = new List <V7VmOpenApiAddressWithMovingIn>
                {
                    new V7VmOpenApiAddressWithMovingIn
                    {
                        Type    = AddressCharacterEnum.Postal.ToString(),
                        SubType = subType
                    }
                }
            };
            var validator = new ServiceLocationChannelValidator(vm, commonService, codeService, serviceService);


            // Act
            validator.Validate(controller.ModelState);

            // Assert
            controller.ModelState.IsValid.Should().BeTrue();
        }