Esempio n. 1
0
        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);
        }
Esempio n. 2
0
 public PostalAddressController(IPostalAddressBusinessService businessService, ILoggingHelper loggingHelper)
 {
     this.businessService = businessService;
     this.loggingHelper   = loggingHelper;
 }