public static IPersonalInfoEnrichmentService BuildService(ILogger logger)
        {
            var settings = new TableStorageSettings()
            {
                ConnectionString = InfrastructureConfiguration.TableStorageConnString
            };

            var initializer = new AzureTableStorageInitializer(settings);

            var storedPersonalInfoRepo = new AzureTableStorageRepository <StoredPersonalInfo>(initializer, logger);
            var personLocalStorage     = new PersonLocalStorage(storedPersonalInfoRepo);

            var contextMappingRepo = new AzureTableStorageRepository <ContextMapping>(initializer, logger);

            var contextMappingLocalStorage = new ContextMappingLocalStorage(contextMappingRepo);

            var authenticationSettings = new AuthenticationSettings(InfrastructureConfiguration.AuthProviderUri,
                                                                    InfrastructureConfiguration.AuthProviderClient,
                                                                    InfrastructureConfiguration.AuthProviderSecret);

            var authenticationProvider = new AuthenticationProvider(authenticationSettings);

            var personalInfoExternalServiceFactory = new PersonalInfoExternalServiceFactory(contextMappingLocalStorage, authenticationProvider, logger);


            return(new PersonalInfoEnrichmentService(personLocalStorage, personalInfoExternalServiceFactory, logger));
        }
Пример #2
0
        public void PersonalInfoExternalServiceFactory_ResolverAPINotFoundForProvidedContext_ReturnsANull()
        {
            var exampleUri = "http://localhost/api/persons/{id}/personaldetails";

            Mock <IContextMappingLocalStorage> contextMappingMock = new Mock <IContextMappingLocalStorage>();

            contextMappingMock.Setup(x => x.Resolve("Youforce.Users")).Returns(exampleUri);

            Mock <IAuthenticationProvider> authProviderMock = new Mock <IAuthenticationProvider>();

            var factory = new PersonalInfoExternalServiceFactory(contextMappingMock.Object, authProviderMock.Object, new Mock <ILogger>().Object);
            var service = factory.Resolve("OtherContext.Users");

            Assert.IsNull(service);
        }