public MockDataManager(ExternalRepositoryManager externalRepositoryManager, FilteringExpressionSetManager filteringExpressionSetManager, UserRepository userRepository, ImportHistoryManager importHistoryManager) { m_externalRepositoryManager = externalRepositoryManager; m_filteringExpressionSetManager = filteringExpressionSetManager; m_userRepository = userRepository; m_importHistoryManager = importHistoryManager; }
public async Task Init() { var mockFactory = new MockRepository(MockBehavior.Loose) { CallBase = true }; var oaiPmhProjectImportManagerMock = mockFactory.Create <OaiPmhProjectImportManager>(new object[1]); oaiPmhProjectImportManagerMock.Setup(x => x.ImportFromResource( It.IsAny <string>(), It.IsAny <ITargetBlock <object> >(), It.IsAny <RepositoryImportProgressInfo>(), It.IsAny <DateTime?>(), It.IsAny <CancellationToken>())) .Callback <string, ITargetBlock <object>, RepositoryImportProgressInfo, DateTime?, CancellationToken>( (config, target, progressInfo, dateTime, cancellationToken) => { if (config == ThrowExc) { throw new ImportFailedException("ImportFailed", "ImportFailed"); } else if (config == ImportTwoRecords) { target.Post(GetRecord(m_mockDataConstant.RecordOaiPmhMarc21JanHus)); target.Post(GetRecord(m_mockDataConstant.RecordOaiPmhMarc21JosefPekar)); progressInfo.TotalProjectsCount = 2; } else { target.Post(GetRecord(config)); progressInfo.TotalProjectsCount = 1; } }) .Returns(Task.CompletedTask); var permissionProviderMock = mockFactory.Create <IPermissionsProvider>(); permissionProviderMock.Setup(x => x.GetRoleIdsByPermissionName(It.IsAny <string>())).Returns((IList <int>)null); var mockIoc = new MockIocContainer(true); mockIoc.ServiceCollection.Replace(new ServiceDescriptor(typeof(IProjectImportManager), oaiPmhProjectImportManagerMock.Object)); mockIoc.ServiceCollection.Replace(new ServiceDescriptor(typeof(IPermissionsProvider), permissionProviderMock.Object)); var serviceProvider = mockIoc.CreateServiceProvider(); m_mainImportManager = serviceProvider.GetRequiredService <MainImportManager>(); m_importHistoryManager = serviceProvider.GetRequiredService <ImportHistoryManager>(); m_mockDataConstant = serviceProvider.GetRequiredService <MockDataConstant>(); m_mockDataManager = serviceProvider.GetRequiredService <MockDataManager>(); m_projectRepository = serviceProvider.GetRequiredService <ProjectRepository>(); var backgroundService = serviceProvider.GetService <IHostedService>(); await backgroundService.StartAsync(CancellationToken.None); }
public ImportPipelineManager(IEnumerable <IProjectImportManager> importManagers, ImportManager importManager, ILogger <ImportPipelineManager> logger, ImportPipelineBuilder importPipelineBuilder, ImportPipelineDirector importPipelineDirector, ExternalRepositoryManager externalRepositoryManager, ImportHistoryManager importHistoryManager) { m_projectImportManagers = new Dictionary <string, IProjectImportManager>(); m_importManager = importManager; m_logger = logger; m_importPipelineBuilder = importPipelineBuilder; m_importPipelineDirector = importPipelineDirector; m_externalRepositoryManager = externalRepositoryManager; m_importHistoryManager = importHistoryManager; foreach (var manager in importManagers) { m_projectImportManagers.Add(manager.ExternalRepositoryTypeName, manager); } }