/// <summary> /// Setup data /// </summary> protected override void OnSetup() { currentUserUnit = "Delivery Office"; mockDeliveryPointsDataService = CreateMock <IDeliveryPointsDataService>(); mockConfigurationDataService = CreateMock <IConfigurationHelper>(); mockLoggingDataService = CreateMock <ILoggingHelper>(); mockDeliveryPointIntegrationService = CreateMock <IDeliveryPointIntegrationService>(); var rmTraceManagerMock = new Mock <IRMTraceManager>(); rmTraceManagerMock.Setup(x => x.StartTrace(It.IsAny <string>(), It.IsAny <Guid>())); mockLoggingDataService.Setup(x => x.RMTraceManager).Returns(rmTraceManagerMock.Object); SqlServerTypes.Utilities.LoadNativeAssemblies(AppDomain.CurrentDomain.BaseDirectory); List <DeliveryPointDTO> lstDeliveryPointDTO = new List <DeliveryPointDTO>(); List <RM.CommonLibrary.EntityFramework.Entities.DeliveryPoint> lstDeliveryPoint = new List <RM.CommonLibrary.EntityFramework.Entities.DeliveryPoint>(); List <PostalAddressDataDTO> lstPostalAddressDTO = new List <PostalAddressDataDTO>() { new PostalAddressDataDTO { BuildingName = "Bldg 1", BuildingNumber = 23, Postcode = "123" } }; deliveryPointDTO = new DeliveryPointDTO() { ID = Guid.NewGuid() }; postalAddressesDTO = new List <PostalAddressDTO>() { new PostalAddressDTO() { BuildingName = "bldg1", BuildingNumber = 1, SubBuildingName = "subbldg", OrganisationName = "org", DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "PostcodeNew", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"), ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A12") }, new PostalAddressDTO() { BuildingName = "bldg1", BuildingNumber = 1, SubBuildingName = "subbldg", OrganisationName = "org", DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "Postcode", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"), ID = Guid.Empty }, new PostalAddressDTO() { BuildingName = "bldg1", BuildingNumber = 1, SubBuildingName = "subbldg", OrganisationName = null, DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "Postcode", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"), ID = Guid.Empty } }; addDeliveryPointDTO = new AddDeliveryPointDTO() { PostalAddressDTO = postalAddressesDTO[0], DeliveryPointDTO = deliveryPointDTO, RangeType = "Odds", DeliveryPointType = "Range", FromRange = 2, ToRange = 11, }; addDeliveryPointDTO1 = new AddDeliveryPointDTO() { PostalAddressDTO = postalAddressesDTO[1], DeliveryPointDTO = deliveryPointDTO }; deliveryPointModelDTO = new DeliveryPointModelDTO() { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"), XCoordinate = 12, YCoordinate = 10, UDPRN = 123, Latitude = 1, Longitude = 2, RowVersion = BitConverter.GetBytes(1) }; actualDeliveryPointDataDto = new List <DeliveryPointDataDTO>() { new DeliveryPointDataDTO() { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"), MailVolume = 5, PostalAddress = new PostalAddressDataDTO() { BuildingName = "bldg1", BuildingNumber = 1, SubBuildingName = "subbldg", OrganisationName = "org", DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "PostcodeNew", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A11"), ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A12") }, NetworkNode = new NetworkNodeDataDTO { ID = Guid.Empty, NetworkNodeType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), Location = new LocationDataDTO() { Shape = DbGeometry.PointFromText("POINT(512722.70000000019 104752.6799999997)", 27700) } }, DeliveryPointStatus = new List <DeliveryPointStatusDataDTO>() { new DeliveryPointStatusDataDTO { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19") } } }, new DeliveryPointDataDTO() { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A17"), MailVolume = 2, PostalAddress = new PostalAddressDataDTO() { BuildingName = "bldg2", BuildingNumber = 1, SubBuildingName = "subbldg1", OrganisationName = "org", DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "PostcodeNew", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19") }, NetworkNode = new NetworkNodeDataDTO { ID = Guid.Empty, NetworkNodeType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), Location = new LocationDataDTO() { Shape = DbGeometry.PointFromText("POINT(512722.70000000019 104752.6799999997)", 27700) } }, DeliveryPointStatus = new List <DeliveryPointStatusDataDTO>() { new DeliveryPointStatusDataDTO { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19") } } } }; actualDeliveryPointDTO = new DeliveryPointDataDTO() { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A17"), MailVolume = 2, PostalAddress = new PostalAddressDataDTO() { BuildingName = "bldg2", BuildingNumber = 1, SubBuildingName = "subbldg1", OrganisationName = "org", DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "PostcodeNew", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19") }, NetworkNode = new NetworkNodeDataDTO { ID = Guid.Empty, NetworkNodeType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), Location = new LocationDataDTO() { Shape = DbGeometry.PointFromText("POINT(512722.70000000019 104752.6799999997)", 27700) } }, DeliveryPointStatus = new List <DeliveryPointStatusDataDTO>() { new DeliveryPointStatusDataDTO { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19") } } }; AddDeliveryPointDTO actualAddDeliveryPointDTO = new AddDeliveryPointDTO() { PostalAddressDTO = new PostalAddressDTO() { BuildingName = "bldg2", BuildingNumber = 1, SubBuildingName = "subbldg1", OrganisationName = "org", DepartmentName = "department", Thoroughfare = "ThoroughFare1", DependentThoroughfare = "DependentThoroughFare1", Postcode = "PostcodeNew", PostTown = "PostTown", POBoxNumber = "POBoxNumber", UDPRN = 12345, PostcodeType = "xyz", SmallUserOrganisationIndicator = "indicator", DeliveryPointSuffix = "DeliveryPointSuffix", PostCodeGUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A15"), AddressType_GUID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19"), ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A19") } }; var locationXy = DbGeometry.PointFromText("POINT(512722.70000000019 104752.6799999997)", 27700); DbGeometry location = DbGeometry.PointFromText("POINT (488938 197021)", 27700); List <RM.CommonLibrary.EntityFramework.DTO.ReferenceDataCategoryDTO> referenceData = GetReferenceDataCategory(); double xLocation = 399545.5590911182; double yLocation = 649744.6394892789; routeDTO = new RouteDTO { RouteName = "Route-001", RouteNumber = "001" }; mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPoints(It.IsAny <string>(), It.IsAny <Guid>(), It.IsAny <string>())).Returns(actualDeliveryPointDataDto); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPoint(It.IsAny <Guid>())).Returns(actualDeliveryPointDTO); mockDeliveryPointsDataService.Setup(x => x.GetDetailDeliveryPointByUDPRN(It.IsAny <int>())).Returns(actualAddDeliveryPointDTO); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointsForBasicSearch(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <Guid>(), currentUserUnit)).ReturnsAsync(actualDeliveryPointDataDto); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointsCount(It.IsAny <string>(), It.IsAny <Guid>(), currentUserUnit)).ReturnsAsync(actualDeliveryPointDataDto.Count); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointsForAdvanceSearch(It.IsAny <string>(), It.IsAny <Guid>(), currentUserUnit)).ReturnsAsync(actualDeliveryPointDataDto); // GetDeliveryPointsForAdvanceSearch mockDeliveryPointsDataService.Setup(x => x.UpdateDeliveryPointLocationOnUDPRN(It.IsAny <DeliveryPointDataDTO>())).Returns(Task.FromResult(1)); mockDeliveryPointsDataService.Setup(x => x.UpdatePAFIndicator(It.IsAny <Guid>(), It.IsAny <Guid>())).ReturnsAsync(true); mockDeliveryPointIntegrationService.Setup(x => x.CheckForDuplicateNybRecords(It.IsAny <PostalAddressDTO>())).Returns(Task.FromResult("ABC")); mockDeliveryPointIntegrationService.Setup(x => x.CheckForDuplicateAddressWithDeliveryPoints(It.IsAny <PostalAddressDTO>())).Returns(Task.FromResult(true)); mockDeliveryPointIntegrationService.Setup(x => x.CreateAddressForDeliveryPoint(It.IsAny <AddDeliveryPointDTO>())).ReturnsAsync(new CreateDeliveryPointModelDTO() { ID = Guid.NewGuid(), IsAddressLocationAvailable = true, Message = "Delivery Point Created", XCoordinate = xLocation, YCoordinate = yLocation }); mockDeliveryPointIntegrationService.Setup(x => x.GetReferenceDataSimpleLists(It.IsAny <List <string> >())).ReturnsAsync(referenceData); mockDeliveryPointIntegrationService.Setup(x => x.GetApproxLocation(It.IsAny <string>())).ReturnsAsync(location); mockDeliveryPointsDataService.Setup(x => x.InsertDeliveryPoint(It.IsAny <DeliveryPointDataDTO>())).ReturnsAsync(Guid.NewGuid()); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointRowVersion(It.IsAny <Guid>())).Returns(BitConverter.GetBytes(1)); mockDeliveryPointIntegrationService.Setup(x => x.MapRouteForDeliveryPoint(It.IsAny <Guid>(), It.IsAny <Guid>())).ReturnsAsync(true); mockDeliveryPointIntegrationService.Setup(x => x.GetReferenceDataGuId(It.IsAny <string>(), It.IsAny <string>())).Returns(Guid.NewGuid()); mockDeliveryPointsDataService.Setup(x => x.UpdateDeliveryPointLocationOnID(It.IsAny <DeliveryPointDataDTO>())).ReturnsAsync(Guid.NewGuid()); mockDeliveryPointIntegrationService.Setup(x => x.CreateAddressForDeliveryPointForRange(It.IsAny <List <PostalAddressDTO> >())).ReturnsAsync(new List <CreateDeliveryPointModelDTO> { new CreateDeliveryPointModelDTO() { ID = new Guid("019DBBBB-03FB-489C-8C8D-F1085E0D2A12"), IsAddressLocationAvailable = true, Message = "Delivery Point Created", XCoordinate = xLocation, YCoordinate = yLocation } }); mockDeliveryPointIntegrationService.Setup(x => x.GetRouteForDeliveryPoint(It.IsAny <Guid>())).ReturnsAsync(routeDTO); mockDeliveryPointsDataService.Setup(x => x.DeliveryPointExists(It.IsAny <int>())).ReturnsAsync(true); mockDeliveryPointsDataService.Setup(x => x.UpdateDeliveryPointLocationOnUDPRN(It.IsAny <DeliveryPointDataDTO>())).ReturnsAsync(5); mockDeliveryPointIntegrationService.Setup(x => x.CreateAccessLink(It.IsAny <Guid>(), It.IsAny <Guid>())).Returns(true); mockDeliveryPointIntegrationService.Setup(x => x.CheckForDuplicateNybRecords(It.IsAny <PostalAddressDTO>())).ReturnsAsync("123"); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointByUDPRN(It.IsAny <int>())).ReturnsAsync(actualDeliveryPointDTO); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointByPostalAddress(It.IsAny <Guid>())).Returns(actualDeliveryPointDTO); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointsCrossingOperationalObject(It.IsAny <string>(), It.IsAny <DbGeometry>())).Returns(actualDeliveryPointDataDto); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPoint(It.IsAny <Guid>())).Returns(actualDeliveryPointDTO); mockDeliveryPointsDataService.Setup(x => x.GetDeliveryPointByPostalAddressWithLocation(It.IsAny <Guid>())).ReturnsAsync(actualDeliveryPointDTO); testCandidate = new DeliveryPointBusinessService(mockDeliveryPointsDataService.Object, mockLoggingDataService.Object, mockConfigurationDataService.Object, mockDeliveryPointIntegrationService.Object); }
public DeliveryPointController(IDeliveryPointBusinessService businessService, ILoggingHelper loggingHelper) { this.businessService = businessService; this.loggingHelper = loggingHelper; }