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(); }
public VmOpenApiServiceLocationChannelInVersionBase MapServiceChannel(int id) { var vmChannel = new VmOpenApiServiceLocationChannelInVersionBase(); try { var url = source.ChannelDetailUrl + id; LogMsg($"Channel url: {url}"); var channelDetails = GetSourceData <SourceChannel>(url); vmChannel = channelDetails.ConvertToVm(organization.Id.ToString(), organization.Oid); if (!string.IsNullOrEmpty(channelDetails.ErrorMsg)) { LogMsg(channelDetails.ErrorMsg); } ValidateObject(vmChannel); } catch (Exception ex) { logger.LogError($"Error occured while mapping a channel { id }. { ex.Message }."); throw; } return(vmChannel); }
public AddServiceChannelTests() { SetupTypesCacheMock <ServiceChannelType>(); list = EntityGenerator.GetServiceChannelEntityList(1, PublishingStatusCache); publishedEntity = list.Where(i => i.PublishingStatusId == PublishedId).FirstOrDefault(); vm = new VmOpenApiServiceLocationChannelInVersionBase() { SourceId = sourceId, PublishingStatus = PublishingStatus.Published.ToString() }; }
[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(); }