public ExternalRepositoryController(ExternalRepositoryManager externalRepositoryManager, AuthenticationManager authenticationManager, MainImportManager mainImportManager) { m_externalRepositoryManager = externalRepositoryManager; m_authenticationManager = authenticationManager; m_mainImportManager = mainImportManager; }
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 RepositoryImportController(MainImportManager mainImportManager, AuthenticationManager authenticationManager) { m_mainImportManager = mainImportManager; m_authenticationManager = authenticationManager; }