public async Task <IActionResult> GetPostalAddress(int?uDPRN) { try { using (loggingHelper.RMTraceManager.StartTrace("Controller.GetPostalAddress")) { string methodName = typeof(PostalAddressController) + "." + nameof(GetPostalAddress); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); PostalAddressDTO postalAddressDTO = await businessService.GetPostalAddress(uDPRN); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(Ok(postalAddressDTO)); } } catch (AggregateException ex) { foreach (var exception in ex.InnerExceptions) { loggingHelper.Log(exception, System.Diagnostics.TraceEventType.Error); } var realExceptions = ex.Flatten().InnerException; throw realExceptions; } }
public void SavePAFDetails_Check_MatchPostalAddressOnAddress_Insert() { PostalAddressDTO objPostalAddress = new PostalAddressDTO() { Time = "7/19/2016", Date = "8:37:00", AmendmentType = "I", AmendmentDesc = "new insert", Postcode = "YO23 1DQ", PostTown = "York", UDPRN = 54162429, DeliveryPointSuffix = "1A", AddressType_GUID = new Guid("A08C5212-6123-4EAF-9C27-D4A8035A8974") }; List <PostalAddressDTO> lstPostalAddress = new List <PostalAddressDTO>(); lstPostalAddress.Add(objPostalAddress); AddressLocationDTO objAddressLocation = new AddressLocationDTO() { UDPRN = 54162428 }; var result = testCandidate.ProcessPAFDetails(lstPostalAddress); Assert.IsNotNull(result); Assert.IsTrue(result.Result); }
public async Task <IActionResult> GetAddressByPostCode(string selectedItem) { try { using (loggingHelper.RMTraceManager.StartTrace("Controller.GetAddressByPostCode")) { string methodName = typeof(UnitManagerController) + "." + nameof(GetAddressByPostCode); loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PostalAddressAPIPriority, LoggerTraceConstants.PostalAddressControllerMethodEntryEventId, LoggerTraceConstants.Title); PostalAddressDTO postalAddressDto = await unitLocationBusinessService.GetPostalAddressDetails(selectedItem, CurrentUserUnit); loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PostalAddressAPIPriority, LoggerTraceConstants.PostalAddressControllerMethodExitEventId, LoggerTraceConstants.Title); return(Ok(postalAddressDto)); } } catch (AggregateException ae) { foreach (var exception in ae.InnerExceptions) { loggingHelper.Log(exception, System.Diagnostics.TraceEventType.Error); } var realExceptions = ae.Flatten().InnerException; throw realExceptions; } }
/// <summary> /// Mapping comma separated value to postalAddressDTO object /// </summary> /// <param name="csvLine">Line read from CSV File</param> /// <returns>Returns mapped DTO</returns> private PostalAddressDTO MapNybDetailsToDTO(string csvLine) { string methodName = MethodBase.GetCurrentMethod().Name; LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionStarted, LoggerTraceConstants.COLON); PostalAddressDTO objAddDTO = new PostalAddressDTO(); string[] values = csvLine.Split(','); if (values.Count() == csvValues) { objAddDTO.Postcode = values[NYBLoaderConstants.NYBPostcode].Trim(); objAddDTO.PostTown = values[NYBLoaderConstants.NYBPostTown]; objAddDTO.DependentLocality = values[NYBLoaderConstants.NYBDependentLocality]; objAddDTO.DoubleDependentLocality = values[NYBLoaderConstants.NYBDoubleDependentLocality]; objAddDTO.Thoroughfare = values[NYBLoaderConstants.NYBThoroughfare]; objAddDTO.DependentThoroughfare = values[NYBLoaderConstants.NYBDependentThoroughfare]; objAddDTO.BuildingNumber = !string.IsNullOrEmpty(values[NYBLoaderConstants.NYBBuildingNumber]) && !string.IsNullOrWhiteSpace(values[NYBLoaderConstants.NYBBuildingNumber]) ? Convert.ToInt16(values[NYBLoaderConstants.NYBBuildingNumber]) : Convert.ToInt16(0); objAddDTO.BuildingName = values[NYBLoaderConstants.NYBBuildingName]; objAddDTO.SubBuildingName = values[NYBLoaderConstants.NYBSubBuildingName]; objAddDTO.POBoxNumber = values[NYBLoaderConstants.NYBPOBoxNumber]; objAddDTO.DepartmentName = values[NYBLoaderConstants.NYBDepartmentName]; objAddDTO.OrganisationName = values[NYBLoaderConstants.NYBOrganisationName]; objAddDTO.UDPRN = !string.IsNullOrEmpty(values[NYBLoaderConstants.NYBUDPRN]) || !string.IsNullOrWhiteSpace(values[NYBLoaderConstants.NYBUDPRN]) ? Convert.ToInt32(values[NYBLoaderConstants.NYBUDPRN]) : 0; objAddDTO.PostcodeType = values[NYBLoaderConstants.NYBPostcodeType]; objAddDTO.SmallUserOrganisationIndicator = values[NYBLoaderConstants.NYBSmallUserOrganisationIndicator]; objAddDTO.DeliveryPointSuffix = values[NYBLoaderConstants.NYBDeliveryPointSuffix].Trim(); objAddDTO.IsValidData = true; } LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionCompleted, LoggerTraceConstants.COLON); return(objAddDTO); }
public async Task <IActionResult> UpdateDPUse([FromBody] PostalAddressDTO postalAddressDetails) { try { using (loggingHelper.RMTraceManager.StartTrace("WebService.UpdateDPUse")) { string methodName = typeof(DeliveryPointController) + "." + nameof(UpdateDPUse); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); bool success = await businessService.UpdateDPUse(postalAddressDetails); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(Ok(success)); } } catch (AggregateException ae) { foreach (var exception in ae.InnerExceptions) { loggingHelper.Log(exception, TraceEventType.Error); } var realExceptions = ae.Flatten().InnerException; throw realExceptions; } }
public async Task Test_GetPAFAddress() { paf = 123; PostalAddressDTO expectedresult = await testCandidate.GetPAFAddress(paf); Assert.IsNotNull(expectedresult); }
public void ProcessPAFDetails_Delete_NegativeScenario2() { PostalAddressDataDTO postalAddressDataDTO = new PostalAddressDataDTO() { AddressType_GUID = Guid.NewGuid() }; mockPostalAddressDataService.Setup(n => n.GetPostalAddress(It.IsAny <int>())).Returns(Task.FromResult(postalAddressDataDTO)); PostalAddressDTO objPostalAddress = new PostalAddressDTO() { Time = "7/19/2016", Date = "8:37:00", AmendmentType = "D", AmendmentDesc = "delete", Postcode = "YO23 1DQ", PostTown = "York", UDPRN = 54162429, DeliveryPointSuffix = "1A", AddressType_GUID = new Guid("C08C5212-6123-4EAF-9C27-D4A8035A8974") }; List <PostalAddressDTO> lstPostalAddress = new List <PostalAddressDTO>(); lstPostalAddress.Add(objPostalAddress); var result = testCandidate.ProcessPAFDetails(lstPostalAddress); Assert.IsNotNull(result); Assert.IsTrue(result.Result); }
public void ProcessPAFDetails_DeleteDPNotFoundScenario() { mockPostalAddressDataService.Setup(x => x.UpdatePostalAddressStatus(It.IsAny <Guid>(), It.IsAny <Guid>())).ReturnsAsync(true); PostalAddressDTO objPostalAddress = new PostalAddressDTO() { Time = "7/19/2016", Date = "8:37:00", AmendmentType = "D", AmendmentDesc = "delete", Postcode = "YO23 1DQ", PostTown = "York", UDPRN = 54162429, DeliveryPointSuffix = "1A", AddressType_GUID = new Guid("A08C5212-6123-4EAF-9C27-D4A8035A8974"), DeliveryPoints = new List <DeliveryPointDTO>() { new DeliveryPointDTO() { ID = new Guid("A08C5212-6123-4EAF-9C27-D4A8035A8974") } } }; List <PostalAddressDTO> lstPostalAddress = new List <PostalAddressDTO>(); lstPostalAddress.Add(objPostalAddress); var result = testCandidate.ProcessPAFDetails(lstPostalAddress); Assert.IsNotNull(result); Assert.IsTrue(result.Result); }
/// <summary> /// Filter PostalAddress based on the post code /// </summary> /// <param name="selectedItem">selectedItem</param> /// <param name="unitGuid">unitGuid</param> /// <returns>List of postcodes</returns> public async Task <PostalAddressDTO> GetPostalAddressDetails(string selectedItem, Guid unitGuid) { using (loggingHelper.RMTraceManager.StartTrace("Business.GetPostalAddressDetails")) { string methodName = typeof(UnitLocationBusinessService) + "." + nameof(GetPostalAddressDetails); loggingHelper.LogMethodEntry(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerBusinessServiceMethodEntryEventId); List <BindingDTO> nybDetails = new List <BindingDTO>(); List <BindingDTO> routeDetails = new List <BindingDTO>(); PostalAddressDTO postalAddressDto = null; var postalAddressDetails = await postalAddressDataService.GetPostalAddressDetails(selectedItem, unitGuid); var routeData = unitManagerIntegrationService.GetRouteData(selectedItem.Split(',')[1].Trim(), "ID,RouteName").Result; routeData.ForEach(route => { routeDetails.Add(new BindingDTO { Value = route.ID, DisplayText = route.RouteName }); }); Guid nybAddressTypeId = unitManagerIntegrationService.GetReferenceDataGuId(PostalAddressType, FileType.Nyb.ToString()).Result; Mapper.Initialize(cfg => { cfg.CreateMap <PostalAddressDataDTO, PostalAddressDTO>(); }); var postalAddressDetailsDTO = Mapper.Map <List <PostalAddressDataDTO>, List <PostalAddressDTO> >(postalAddressDetails); if (postalAddressDetailsDTO != null && postalAddressDetailsDTO.Count > 0) { postalAddressDto = postalAddressDetailsDTO[0]; foreach (var postalAddress in postalAddressDetailsDTO) { if (postalAddress.AddressType_GUID == nybAddressTypeId) { string address = string.Join(",", Convert.ToString(postalAddress.BuildingNumber) ?? string.Empty, postalAddress.BuildingName, postalAddress.SubBuildingName); string formattedAddress = Regex.Replace(address, ",+", ",").Trim(','); nybDetails.Add(new BindingDTO { Value = postalAddress.ID, DisplayText = formattedAddress }); } } nybDetails.OrderBy(n => n.DisplayText); nybDetails.Add(new BindingDTO { Value = Guid.Empty, DisplayText = "Not Shown" }); postalAddressDto.NybAddressDetails = nybDetails; postalAddressDto.RouteDetails = routeDetails; } loggingHelper.LogMethodExit(methodName, LoggerTraceConstants.UnitManagerAPIPriority, LoggerTraceConstants.UnitManagerBusinessServiceMethodExitEventId); return(postalAddressDto); } }
public IActionResult GetPostalAddressByGuid(Guid addressGuid) { using (loggingHelper.RMTraceManager.StartTrace("Controller.GetPostalAddressByGuid")) { string methodName = typeof(PostalAddressController) + "." + nameof(GetPostalAddressByGuid); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); PostalAddressDTO postalAddressDto = businessService.GetPostalAddressDetails(addressGuid); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(Ok(postalAddressDto)); } }
public async Task <IActionResult> CheckForDuplicateAddressWithDeliveryPoints([FromBody] PostalAddressDTO objPostalAddress) { using (loggingHelper.RMTraceManager.StartTrace("Controller.CheckForDuplicateAddressWithDeliveryPoints")) { string methodName = typeof(PostalAddressController) + "." + nameof(CheckForDuplicateAddressWithDeliveryPoints); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); bool isDuplicate = await businessService.CheckForDuplicateAddressWithDeliveryPoints(objPostalAddress); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(Ok(isDuplicate)); } }
public async Task Test_UpdateDPUse_NegativeScenario3() { try { var postalAddressDTO = new PostalAddressDTO() { UDPRN = null, OrganisationName = "abc" }; bool result = await testCandidate.UpdateDPUse(postalAddressDTO); Assert.Fail("An exception should have been thrown"); } catch (ArgumentNullException ae) { Assert.AreEqual("Value cannot be null.Parameter name: postalAddressDetails", ae.Message.Replace("\r\n", string.Empty)); } }
/// <summary> /// This method is used to check Duplicate NYB records /// </summary> /// <param name="objPostalAddress">objPostalAddress as input</param> /// <returns>string</returns> public async Task <string> CheckForDuplicateNybRecords(PostalAddressDTO objPostalAddress) { using (loggingHelper.RMTraceManager.StartTrace("IntegrationService.CheckForDuplicateNybRecords")) { string methodName = typeof(DeliveryPointIntegrationService) + "." + nameof(CheckForDuplicateNybRecords); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); HttpResponseMessage result = await httpHandler.PostAsJsonAsync(postalAddressManagerWebAPIName + "postaladdress/nybduplicate/", objPostalAddress); if (!result.IsSuccessStatusCode) { var responseContent = result.ReasonPhrase; throw new ServiceException(responseContent); } var checkForDuplicateNybRecords = result.Content.ReadAsStringAsync().Result; loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(checkForDuplicateNybRecords); } }
/// <summary> /// Update DPUse in delivery point for matching UDPRN /// </summary> /// <param name="postalAddressDetails">postal address record in PAF</param> /// <returns>Flag to indicate DPUse updated or not</returns> public async Task <bool> UpdateDPUse(PostalAddressDTO postalAddressDetails) { using (loggingHelper.RMTraceManager.StartTrace("IntegrationService.UpdateDPUse")) { string methodName = typeof(PostalAddressIntegrationService) + "." + nameof(UpdateDPUse); loggingHelper.LogMethodEntry(methodName, priority, entryEventId); HttpResponseMessage result = await httpHandler.PostAsJsonAsync(deliveryPointManagerWebAPIName + "deliverypoint/UpdateDPUse/", postalAddressDetails); if (!result.IsSuccessStatusCode) { var responseContent = result.ReasonPhrase; throw new ServiceException(responseContent); } var isDPUseUpdated = JsonConvert.DeserializeObject <bool>(result.Content.ReadAsStringAsync().Result); loggingHelper.LogMethodExit(methodName, priority, exitEventId); return(isDPUseUpdated); } }
/// <summary> /// PAFMessageReceived to process the PAF messages popped out of the queue. /// </summary> public void PAFMessageReceived() { using (loggingHelper.RMTraceManager.StartTrace("Service.PAFMessageReceived")) { string methodName = MethodBase.GetCurrentMethod().Name; try { loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionStarted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PAFPriority, LoggerTraceConstants.PAFReceiverMethodEntryEventId, LoggerTraceConstants.Title); List <PostalAddressDTO> lstPostalAddress = new List <PostalAddressDTO>(); //The Message queue is checked whether there are pending messages in the queue. This loop runs till all the messages are popped out of the message queue. while (msgPAF.HasMessage(QUEUEPAF, QUEUEPATH)) { //Receive Message picks up one message from queue for processing //Message broker internally deserializes the message to the POCO type. PostalAddressDTO objPostalAddress = msgPAF.ReceiveMessage(QUEUEPAF, QUEUEPATH); if (objPostalAddress != null) { lstPostalAddress.Add(objPostalAddress); } } if (lstPostalAddress != null && lstPostalAddress.Count > 0) { m_mainTimer.Elapsed -= new ElapsedEventHandler(m_mainTimer_Elapsed); var result = SavePAFDetails(lstPostalAddress).ContinueWith(p => { m_mainTimer.Elapsed += new ElapsedEventHandler(m_mainTimer_Elapsed); }); } } catch (Exception ex) { this.loggingHelper.Log(ex, TraceEventType.Error); } loggingHelper.Log(methodName + LoggerTraceConstants.COLON + LoggerTraceConstants.MethodExecutionCompleted, TraceEventType.Verbose, null, LoggerTraceConstants.Category, LoggerTraceConstants.PAFPriority, LoggerTraceConstants.PAFReceiverMethodExitEventId, LoggerTraceConstants.Title); } }
/// <summary> /// Mapping comma separated value to PostalAddressDTO object /// </summary> /// <param name="csvLine">Line read from CSV File</param> /// <param name="fileName">File Name</param> /// <returns>Returns mapped DTO</returns> private PostalAddressDTO MapPAFDetailsToDTO(string csvLine, string fileName) { PostalAddressDTO objAddDTO = new PostalAddressDTO(); string methodName = MethodBase.GetCurrentMethod().Name; LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionStarted, LoggerTraceConstants.COLON); string[] values = csvLine.Split(PAFLoaderConstants.CommaChar); if (values.Count() == csvPAFValues) { objAddDTO.Date = values[PAFLoaderConstants.PAFDate] = values[PAFLoaderConstants.PAFDate] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFDate]) ? null : values[PAFLoaderConstants.PAFDate]; objAddDTO.Time = values[PAFLoaderConstants.PAFTime] = values[PAFLoaderConstants.PAFTime] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFTime]) ? null : values[PAFLoaderConstants.PAFTime]; objAddDTO.AmendmentType = values[PAFLoaderConstants.PAFAmendmentType] = values[PAFLoaderConstants.PAFAmendmentType] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFAmendmentType]) ? null : values[PAFLoaderConstants.PAFAmendmentType]; objAddDTO.AmendmentDesc = values[PAFLoaderConstants.PAFAmendmentDesc] = values[PAFLoaderConstants.PAFAmendmentDesc] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFAmendmentDesc]) ? null : values[PAFLoaderConstants.PAFAmendmentDesc]; objAddDTO.Postcode = values[PAFLoaderConstants.PAFPostcode] = values[PAFLoaderConstants.PAFPostcode] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFPostcode]) ? null : values[PAFLoaderConstants.PAFPostcode]; objAddDTO.PostTown = values[PAFLoaderConstants.PAFPostTown] = values[PAFLoaderConstants.PAFPostTown] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFPostTown]) ? null : values[PAFLoaderConstants.PAFPostTown]; objAddDTO.DependentLocality = values[PAFLoaderConstants.PAFDependentLocality] = values[PAFLoaderConstants.PAFDependentLocality] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFDependentLocality]) ? null : values[PAFLoaderConstants.PAFDependentLocality]; objAddDTO.DoubleDependentLocality = values[PAFLoaderConstants.PAFDoubleDependentLocality] = values[PAFLoaderConstants.PAFDoubleDependentLocality] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFDoubleDependentLocality]) ? null : values[PAFLoaderConstants.PAFDoubleDependentLocality]; objAddDTO.Thoroughfare = values[PAFLoaderConstants.PAFThoroughfare] = values[PAFLoaderConstants.PAFThoroughfare] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFThoroughfare]) ? null : values[PAFLoaderConstants.PAFThoroughfare]; objAddDTO.DependentThoroughfare = values[PAFLoaderConstants.PAFDependentThoroughfare] = values[PAFLoaderConstants.PAFDependentThoroughfare] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFDependentThoroughfare]) ? null : values[PAFLoaderConstants.PAFDependentThoroughfare]; objAddDTO.BuildingNumber = (!string.IsNullOrEmpty(values[PAFLoaderConstants.PAFBuildingNumber]) && !string.IsNullOrWhiteSpace(values[PAFLoaderConstants.PAFBuildingNumber])) ? Convert.ToInt16(values[PAFLoaderConstants.PAFBuildingNumber]) as short? : null; objAddDTO.BuildingName = values[PAFLoaderConstants.PAFBuildingName] = values[PAFLoaderConstants.PAFBuildingName] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFBuildingName]) ? null : values[PAFLoaderConstants.PAFBuildingName]; objAddDTO.SubBuildingName = values[PAFLoaderConstants.PAFSubBuildingName] = values[PAFLoaderConstants.PAFSubBuildingName] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFSubBuildingName]) ? null : values[PAFLoaderConstants.PAFSubBuildingName]; objAddDTO.POBoxNumber = values[PAFLoaderConstants.PAFPOBoxNumber] = values[PAFLoaderConstants.PAFPOBoxNumber] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFPOBoxNumber]) ? null : values[PAFLoaderConstants.PAFPOBoxNumber]; objAddDTO.DepartmentName = values[PAFLoaderConstants.PAFDepartmentName] = values[PAFLoaderConstants.PAFDepartmentName] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFDepartmentName]) ? null : values[PAFLoaderConstants.PAFDepartmentName]; objAddDTO.OrganisationName = values[PAFLoaderConstants.PAFOrganisationName] = values[PAFLoaderConstants.PAFOrganisationName] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFOrganisationName]) ? null : values[PAFLoaderConstants.PAFOrganisationName]; objAddDTO.UDPRN = !string.IsNullOrEmpty(values[PAFLoaderConstants.PAFUDPRN]) && !string.IsNullOrWhiteSpace(values[PAFLoaderConstants.PAFUDPRN]) ? Convert.ToInt32(values[PAFLoaderConstants.PAFUDPRN]) : 0; objAddDTO.PostcodeType = values[PAFLoaderConstants.PAFPostcodeType] = values[PAFLoaderConstants.PAFPostcodeType] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFPostcodeType]) ? null : values[PAFLoaderConstants.PAFPostcodeType]; objAddDTO.SmallUserOrganisationIndicator = values[PAFLoaderConstants.PAFSmallUserOrganisationIndicator] = values[PAFLoaderConstants.PAFSmallUserOrganisationIndicator] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFSmallUserOrganisationIndicator]) ? null : values[PAFLoaderConstants.PAFSmallUserOrganisationIndicator]; objAddDTO.DeliveryPointSuffix = values[PAFLoaderConstants.PAFDeliveryPointSuffix] = values[PAFLoaderConstants.PAFDeliveryPointSuffix] = string.IsNullOrEmpty(values[PAFLoaderConstants.PAFDeliveryPointSuffix]) ? null : values[PAFLoaderConstants.PAFDeliveryPointSuffix]; objAddDTO.IsValidData = true; objAddDTO.FileName = fileName; } LogMethodInfoBlock(methodName, LoggerTraceConstants.MethodExecutionCompleted, LoggerTraceConstants.COLON); return(objAddDTO); }
public void ProcessPAFDetails_Update_NegativeScenario2() { mockPostalAddressIntegrationService.Setup(n => n.UpdateDPUse(It.IsAny <PostalAddressDTO>())).ReturnsAsync(false); mockPostalAddressDataService.Setup(x => x.UpdateAddress(It.IsAny <PostalAddressDataDTO>(), It.IsAny <string>())).ReturnsAsync(true); PostalAddressDTO objPostalAddress = new PostalAddressDTO() { Time = "7/19/2016", Date = "8:37:00", AmendmentType = "C", AmendmentDesc = "update", Postcode = "YO23 1DQ", PostTown = "York", UDPRN = 54162429, DeliveryPointSuffix = "1A", AddressType_GUID = new Guid("A08C5212-6123-4EAF-9C27-D4A8035A8974") }; List <PostalAddressDTO> lstPostalAddress = new List <PostalAddressDTO>(); lstPostalAddress.Add(objPostalAddress); var result = testCandidate.ProcessPAFDetails(lstPostalAddress); Assert.IsNotNull(result); Assert.IsTrue(result.Result); }
protected override void OnSetup() { searchIntegrationServiceMock = new Mock <ISearchIntegrationService>(); loggingHelperMock = new Mock <ILoggingHelper>(); postalAddressDTO = new PostalAddressDTO() { BuildingName = "abc" }; List <ReferenceDataCategoryDTO> referenceDataCategoryDTOList = new List <ReferenceDataCategoryDTO>() { new ReferenceDataCategoryDTO() { CategoryName = ReferenceDataCategoryNames.OperationalObjectType, ReferenceDatas = new List <ReferenceDataDTO>() { new ReferenceDataDTO() { ReferenceDataName = null, ReferenceDataValue = ReferenceDataValues.OperationalObjectTypeDP, ID = Guid.Parse("4DBA7B39-D23E-493A-9B8F-B94D181A082F") }, new ReferenceDataDTO() { ReferenceDataName = null, ReferenceDataValue = ReferenceDataValues.DeliveryUnit, ID = unitLocationTypeId } } } }; searchIntegrationServiceMock.Setup(x => x.FetchDeliveryRouteForAdvanceSearch(It.IsAny <string>())).Returns(Task.FromResult(new List <RouteDTO>() { new RouteDTO { RouteName = "Route 1" } })); searchIntegrationServiceMock.Setup(x => x.FetchPostCodeUnitForAdvanceSearch(It.IsAny <string>())).Returns(Task.FromResult(new List <PostCodeDTO>() { new PostCodeDTO { PostcodeUnit = "001" } })); searchIntegrationServiceMock.Setup(x => x.FetchStreetNamesForAdvanceSearch(It.IsAny <string>())).Returns(Task.FromResult(new List <StreetNameDTO>() { new StreetNameDTO { LocalName = "Route 1" } })); searchIntegrationServiceMock.Setup(x => x.FetchDeliveryPointsForAdvanceSearch(It.IsAny <string>())).Returns(Task.FromResult(new List <DeliveryPointDTO>() { new DeliveryPointDTO { LocationProvider = "Route 1", PostalAddress = postalAddressDTO } })); searchIntegrationServiceMock.Setup(x => x.FetchDeliveryRouteForBasicSearch(It.IsAny <string>())).Returns(Task.FromResult(new List <RouteDTO>() { new RouteDTO { RouteName = "Route 1" } })); searchIntegrationServiceMock.Setup(x => x.FetchPostCodeUnitForBasicSearch(It.IsAny <string>())).Returns(Task.FromResult(new List <PostCodeDTO>() { new PostCodeDTO { PostcodeUnit = "001" } })); searchIntegrationServiceMock.Setup(x => x.FetchStreetNamesForBasicSearch(It.IsAny <string>())).Returns(Task.FromResult(new List <StreetNameDTO>() { new StreetNameDTO { LocalName = "Route 1" } })); searchIntegrationServiceMock.Setup(x => x.FetchDeliveryPointsForBasicSearch(It.IsAny <string>())).Returns(Task.FromResult(new List <DeliveryPointDTO>() { new DeliveryPointDTO { LocationProvider = "Route 1", PostalAddress = postalAddressDTO } })); searchIntegrationServiceMock.Setup(x => x.GetDeliveryRouteCount(It.IsAny <string>())).Returns(Task.FromResult(1)); searchIntegrationServiceMock.Setup(x => x.GetPostCodeUnitCount(It.IsAny <string>())).Returns(Task.FromResult(1)); searchIntegrationServiceMock.Setup(x => x.GetStreetNameCount(It.IsAny <string>())).Returns(Task.FromResult(1)); searchIntegrationServiceMock.Setup(x => x.GetDeliveryPointsCount(It.IsAny <string>())).Returns(Task.FromResult(1)); searchIntegrationServiceMock.Setup(n => n.GetReferenceDataSimpleLists(It.IsAny <List <string> >())).Returns(Task.FromResult(referenceDataCategoryDTOList)); searchIntegrationServiceMock.Setup(n => n.GetUnitLocationTypeId(It.IsAny <Guid>())).Returns(Task.FromResult(unitLocationTypeId)); var rmTraceManagerMock = new Mock <IRMTraceManager>(); rmTraceManagerMock.Setup(x => x.StartTrace(It.IsAny <string>(), It.IsAny <Guid>())); loggingHelperMock.Setup(x => x.RMTraceManager).Returns(rmTraceManagerMock.Object); testCandidate = new SearchBusinessService(searchIntegrationServiceMock.Object, loggingHelperMock.Object); }
protected override void OnSetup() { // OnSetup to be configured referenceDataCategoryDTOList = new List <CommonLibrary.EntityFramework.DTO.ReferenceDataCategoryDTO>() { new CommonLibrary.EntityFramework.DTO.ReferenceDataCategoryDTO() { ReferenceDatas = new List <CommonLibrary.EntityFramework.DTO.ReferenceDataDTO>() { new CommonLibrary.EntityFramework.DTO.ReferenceDataDTO() { ReferenceDataValue = FileType.Nyb.ToString(), ID = Guid.NewGuid(), } }, CategoryName = PostalAddressType }, new CommonLibrary.EntityFramework.DTO.ReferenceDataCategoryDTO() { ReferenceDatas = new List <CommonLibrary.EntityFramework.DTO.ReferenceDataDTO>() { new CommonLibrary.EntityFramework.DTO.ReferenceDataDTO() { ReferenceDataValue = FileType.Usr.ToString(), ID = Guid.NewGuid(), } }, CategoryName = PostalAddressType }, new CommonLibrary.EntityFramework.DTO.ReferenceDataCategoryDTO() { ReferenceDatas = new List <CommonLibrary.EntityFramework.DTO.ReferenceDataDTO>() { new CommonLibrary.EntityFramework.DTO.ReferenceDataDTO() { ReferenceDataValue = FileType.Paf.ToString(), ID = new Guid("A08C5212-6123-4EAF-9C27-D4A8035A8974"), } }, CategoryName = PostalAddressType }, new CommonLibrary.EntityFramework.DTO.ReferenceDataCategoryDTO() { ReferenceDatas = new List <CommonLibrary.EntityFramework.DTO.ReferenceDataDTO>() { new CommonLibrary.EntityFramework.DTO.ReferenceDataDTO() { ReferenceDataValue = PostCodeStatus.Live.GetDescription(), ID = Guid.NewGuid(), } }, CategoryName = PostalAddressStatus }, new CommonLibrary.EntityFramework.DTO.ReferenceDataCategoryDTO() { ReferenceDatas = new List <CommonLibrary.EntityFramework.DTO.ReferenceDataDTO>() { new CommonLibrary.EntityFramework.DTO.ReferenceDataDTO() { ReferenceDataValue = PostCodeStatus.PendingDeleteInFMO.GetDescription(), ID = Guid.NewGuid(), } }, CategoryName = PostalAddressStatus } }; AddressLocationDTO addressLocationDTO = new AddressLocationDTO() { UDPRN = 1234, LocationXY = DbGeometry.PointFromText("POINT(512722.70000000019 104752.6799999997)", 27700) }; PostalAddressDataDTO postalAddressDataDTO = new PostalAddressDataDTO() { Postcode = "YO23 1DQ", PostTown = "York", UDPRN = 54162429, DeliveryPointSuffix = "1A", AddressType_GUID = new Guid("A08C5212-6123-4EAF-9C27-D4A8035A8974") }; PostalAddressDTO postalAddressDTO = new PostalAddressDTO() { ID = Guid.Empty }; mockPostalAddressDataService = CreateMock <IPostalAddressDataService>(); // mockFileProcessingLogDataService = CreateMock<IFileProcessingLogDataService>(); mockConfigurationHelper = CreateMock <IConfigurationHelper>(); mockLoggingHelper = CreateMock <ILoggingHelper>(); mockHttpHandler = CreateMock <IHttpHandler>(); mockPostalAddressIntegrationService = CreateMock <IPostalAddressIntegrationService>(); var rmTraceManagerMock = new Mock <IRMTraceManager>(); rmTraceManagerMock.Setup(x => x.StartTrace(It.IsAny <string>(), It.IsAny <Guid>())); mockLoggingHelper.Setup(x => x.RMTraceManager).Returns(rmTraceManagerMock.Object); mockPostalAddressIntegrationService.Setup(n => n.GetReferenceDataSimpleLists(It.IsAny <string>())).Returns(Task.FromResult(referenceDataCategoryDTOList[2])); mockPostalAddressIntegrationService.Setup(n => n.GetReferenceDataSimpleLists(It.IsAny <List <string> >())).Returns(Task.FromResult(referenceDataCategoryDTOList)); mockPostalAddressIntegrationService.Setup(n => n.GetReferenceDataGuId(It.IsAny <string>(), It.IsAny <string>())).Returns(Task.FromResult(Guid.NewGuid())); mockPostalAddressIntegrationService.Setup(n => n.GetAddressLocationByUDPRN(It.IsAny <int>())).Returns(Task.FromResult(addressLocationDTO)); mockPostalAddressDataService.Setup(n => n.DeleteNYBPostalAddress(It.IsAny <List <int> >(), It.IsAny <Guid>())).Returns(Task.FromResult(true)); mockPostalAddressDataService.Setup(n => n.GetPostalAddresses(It.IsAny <List <Guid> >())).ReturnsAsync(new List <PostalAddressDataDTO>() { new PostalAddressDataDTO() { Postcode = "1234" } }); mockPostalAddressDataService.Setup(n => n.CheckForDuplicateNybRecords(It.IsAny <PostalAddressDataDTO>(), It.IsAny <Guid>())).Returns("PO1234"); mockPostalAddressDataService.Setup(n => n.CheckForDuplicateAddressWithDeliveryPoints(It.IsAny <PostalAddressDataDTO>())).Returns(Task.FromResult(true)); mockPostalAddressDataService.Setup(n => n.CreateAddressForDeliveryPoint(It.IsAny <PostalAddressDataDTO>())).Returns(addressTypeGUID); mockPostalAddressDataService.Setup(n => n.GetPostalAddress(It.IsAny <int>())).Returns(Task.FromResult(postalAddressDataDTO)); mockPostalAddressDataService.Setup(n => n.GetPAFAddress(It.IsAny <int>(), It.IsAny <Guid>())).Returns(Task.FromResult(postalAddressDTO)); // mockFileProcessingLogDataService.Setup(x => x.LogFileException(It.IsAny<FileProcessingLogDTO>())); testCandidate = new DataManagement.PostalAddress.WebAPI.BusinessService.Implementation.PostalAddressBusinessService(mockPostalAddressDataService.Object, mockLoggingHelper.Object, mockConfigurationHelper.Object, mockHttpHandler.Object, mockPostalAddressIntegrationService.Object); }