public void delete_returns_true_if_entity_is_deleted(int id) { var sut = new RepositoryBuilder() .Build(); sut.Save( new TestEntity { Id = id }); Assert.NotNull(sut.Get(id)); Assert.True(sut.Delete(id)); Assert.Null(sut.Get(id)); }
public void Evaluator_Eval_Custom() { const string script = "[Script:testTag]...myscript...[/Script]"; var original = Providers.Instance.GetProvider <IEvaluator>(Evaluator.GetFullTagName("testTag")); var repo = new RepositoryBuilder(); repo.UseScriptEvaluator(new CustomTestEvaluator()); // the custom evaluator should be in control Assert.AreEqual("custom", Evaluator.Evaluate(script)); // back to the original repo.UseScriptEvaluator(original); Assert.AreEqual("success", Evaluator.Evaluate(script)); }
public void RepositoryStart_NamedProviders() { var dbProvider = new InMemoryDataProvider(); var securityDbProvider = new MemoryDataProvider(DatabaseStorage.CreateEmpty()); var searchEngine = new InMemorySearchEngine(GetInitialIndex()); var accessProvider = new DesktopAccessProvider(); var emvrProvider = new ElevatedModificationVisibilityRule(); // switch this ON here for testing purposes (to check that repo start does not override it) SnTrace.Custom.Enabled = true; var repoBuilder = new RepositoryBuilder() .UseAccessProvider(new DesktopAccessProvider()) .UseDataProvider(dbProvider) .UseInitialData(GetInitialData()) .UseBlobMetaDataProvider(new InMemoryBlobStorageMetaDataProvider(dbProvider)) .UseBlobProviderSelector(new InMemoryBlobProviderSelector()) .UseSecurityDataProvider(securityDbProvider) .UseSearchEngine(searchEngine) .UseAccessProvider(accessProvider) .UseElevatedModificationVisibilityRuleProvider(emvrProvider) .StartIndexingEngine(false) .StartWorkflowEngine(false) .UseTraceCategories("Test", "Web", "System"); using (Repository.Start(repoBuilder)) { Assert.AreSame(dbProvider, DataStore.DataProvider); Assert.AreEqual(searchEngine, SearchManager.SearchEngine); Assert.AreEqual(accessProvider, AccessProvider.Current); Assert.AreEqual(emvrProvider, Providers.Instance.ElevatedModificationVisibilityRuleProvider); // Currently this does not work, because the property below re-creates the security // db provider from the prototype, so it cannot be ref equal with the original. // Assert.AreEqual(securityDbProvider, SecurityHandler.SecurityContext.DataProvider); Assert.AreEqual(securityDbProvider, Providers.Instance.SecurityDataProvider); // Check a few trace categories that were switched ON above. Assert.IsTrue(SnTrace.Custom.Enabled); Assert.IsTrue(SnTrace.Test.Enabled); Assert.IsTrue(SnTrace.Web.Enabled); Assert.IsTrue(SnTrace.System.Enabled); Assert.IsFalse(SnTrace.TaskManagement.Enabled); Assert.IsFalse(SnTrace.Workflow.Enabled); } }
public void WhenTheUserCreatesANewGitHubRepository() { var repository = RepositoryBuilder.BuildRepository(); var jobj = JsonConvert.SerializeObject(repository); //Create a new repository var result = RESTHelpers.POSTRequestAsync <RepositoryResponseDTO>( ConfigurationManager.AppSettings["URL"], ConfigurationManager.AppSettings["RepositoryResource"], HeaderBuilder.BuildHeader(), ConfigurationManager.AppSettings["UserName"], ConfigurationManager.AppSettings["Password"], JObject.Parse(jobj)).Result; context.Add("RepositoryDTO", repository); context.Add("RepositoryResponseDTO", result); }
public void delete_all_does_not_pass_entity_through_to_subclass() { var called = false; var sut = new RepositoryBuilder() .WithOnEntityDeleted( (e, c) => called = true) .Build(); var result = sut .Save( new TestEntity { Column1 = "original" }); Assert.False(called); sut.DeleteAll(); Assert.False(called); }
public void delete_passes_entity_through_to_subclass_if_it_is_deleted() { var called = false; var sut = new RepositoryBuilder() .WithOnEntityDeleted( (e, c) => called = true) .Build(); var result = sut .Save( new TestEntity { Column1 = "original" }); Assert.False(called); sut.Delete(result.Id.Value); Assert.True(called); }
public void AddTransaction_OnError_AccountUnlocks() { //Arrange var builder = new RepositoryBuilder(); var context = builder.DefaultAccountDbContext(); var transaction = GetTestableTransaction(context); context.Setup(x => x.SaveChanges()).Throws(new UnitTestException("Unit test exception")); var service = builder.WithAccountDbContext(context.Object).Build(); //Act Action action = () => service.AddTransaction(transaction); //Assert action.Should().Throw <UnitTestException>(); transaction.Account.Locked.Should().BeFalse(); }
public void RepositoryStart_NullPopulator() { var dbProvider2 = new InMemoryDataProvider(); Providers.Instance.DataProvider = dbProvider2; var securityDbProvider = new MemoryDataProvider(DatabaseStorage.CreateEmpty()); var searchEngine = new InMemorySearchEngine(GetInitialIndex()); var accessProvider = new DesktopAccessProvider(); var emvrProvider = new ElevatedModificationVisibilityRule(); var repoBuilder = new RepositoryBuilder() .UseAccessProvider(new DesktopAccessProvider()) .UseDataProvider(dbProvider2) .UseInitialData(GetInitialData()) .UseBlobMetaDataProvider(new InMemoryBlobStorageMetaDataProvider(dbProvider2)) .UseBlobProviderSelector(new InMemoryBlobProviderSelector()) .AddBlobProvider(new InMemoryBlobProvider()) .UseSecurityDataProvider(securityDbProvider) .UseSecurityMessageProvider(new DefaultMessageProvider(new MessageSenderManager())) .UseSearchEngine(searchEngine) .UseAccessProvider(accessProvider) .UseElevatedModificationVisibilityRuleProvider(emvrProvider) .StartIndexingEngine(false) .StartWorkflowEngine(false) .UseTraceCategories("Test", "Web", "System"); var originalIsOuterSearchEngineEnabled = Indexing.IsOuterSearchEngineEnabled; Indexing.IsOuterSearchEngineEnabled = false; try { using (Repository.Start(repoBuilder)) { Assert.IsFalse(SearchManager.IsOuterEngineEnabled); Assert.AreEqual(typeof(InternalSearchEngine), SearchManager.SearchEngine.GetType()); var populator = SearchManager.GetIndexPopulator(); Assert.AreEqual(typeof(NullPopulator), populator.GetType()); } } finally { Indexing.IsOuterSearchEngineEnabled = originalIsOuterSearchEngineEnabled; } }
public void RepositoryStart_AuditEventWriter_Database() { var originalWriter = SnLog.AuditEventWriter; var auditWriter = new DatabaseAuditEventWriter(); var dbProvider = new InMemoryDataProvider(); var securityDbProvider = new MemoryDataProvider(DatabaseStorage.CreateEmpty()); var searchEngine = new InMemorySearchEngine(GetInitialIndex()); var accessProvider = new DesktopAccessProvider(); var emvrProvider = new ElevatedModificationVisibilityRule(); try { // Clear the slot to ensure a real test. Providers.Instance.AuditEventWriter = null; var repoBuilder = new RepositoryBuilder() .UseAccessProvider(new DesktopAccessProvider()) .UseDataProvider(dbProvider) .UseAuditEventWriter(auditWriter) // <-- The important line .UseInitialData(GetInitialData()) .UseBlobMetaDataProvider(new InMemoryBlobStorageMetaDataProvider(dbProvider)) .UseBlobProviderSelector(new InMemoryBlobProviderSelector()) .AddBlobProvider(new InMemoryBlobProvider()) .UseSecurityDataProvider(securityDbProvider) .UseSecurityMessageProvider(new DefaultMessageProvider(new MessageSenderManager())) .UseSearchEngine(searchEngine) .UseAccessProvider(accessProvider) .UseElevatedModificationVisibilityRuleProvider(emvrProvider) .StartIndexingEngine(false) .StartWorkflowEngine(false) .UseTraceCategories("Test", "Web", "System"); using (Repository.Start(repoBuilder)) { Assert.AreSame(auditWriter, Providers.Instance.AuditEventWriter); Assert.AreSame(auditWriter, SnLog.AuditEventWriter); } } finally { SnLog.AuditEventWriter = originalWriter; } }
/// <summary> /// Executes the /// <code>Init</code> /// command. /// </summary> /// <exception cref="NGit.Api.Errors.JGitInternalException">if the repository can't be created /// </exception> /// <returns> /// the newly created /// <code>Git</code> /// object with associated repository /// </returns> public virtual Git Call() { try { RepositoryBuilder builder = new RepositoryBuilder(); if (bare) { builder.SetBare(); } builder.ReadEnvironment(); if (directory != null) { FilePath d = directory; if (!bare) { d = new FilePath(d, Constants.DOT_GIT); } builder.SetGitDir(d); } else { if (builder.GetGitDir() == null) { FilePath d = new FilePath("."); if (d.GetParentFile() != null) { d = d.GetParentFile(); } if (!bare) { d = new FilePath(d, Constants.DOT_GIT); } builder.SetGitDir(d); } } Repository repository = builder.Build(); repository.Create(bare); return(new Git(repository)); } catch (IOException e) { throw new JGitInternalException(e.Message, e); } }
public void get_all_returns_all_entities() { var sut = new RepositoryBuilder() .Build(); sut.SaveAll( Enumerable .Range(0, 100) .Select(i => new TestEntity { Id = i })); var results = sut.GetAll(); Assert.NotNull(results); Assert.Equal(100, results.Count); }
/// <summary> /// Adds all test policies that are required by test methods - even UnknownPolicy. /// </summary> public static RepositoryBuilder AddAllTestPolicies(this RepositoryBuilder builder) { return(builder.UseOperationMethodExecutionPolicy("Policy1", new ODataOperationMethodTests.AllowEverythingPolicy()) .UseOperationMethodExecutionPolicy("Policy2", new ODataOperationMethodTests.AllowEverythingPolicy()) .UseOperationMethodExecutionPolicy("Policy3", new ODataOperationMethodTests.AllowEverythingPolicy()) .UseOperationMethodExecutionPolicy("UnknownPolicy", new ODataOperationMethodTests.AllowEverythingPolicy()) .UseOperationMethodExecutionPolicy("ContentNameMustBeRoot", (user, context) => context.Content.Name == "Root" ? OperationMethodVisibility.Enabled : OperationMethodVisibility.Invisible) .UseOperationMethodExecutionPolicy("VisitorAllowed", (user, context) => user.Id == Identifiers.VisitorUserId ? OperationMethodVisibility.Enabled : OperationMethodVisibility.Disabled) .UseOperationMethodExecutionPolicy("AdminDenied", new ODataOperationMethodTests.DeniedUsersOperationMethodPolicy(new[] { Identifiers.AdministratorUserId }))); }
public void RepositoryStart_NodeObservers_DisableAll() { var repoBuilder = new RepositoryBuilder() .UseDataProvider(new InMemoryDataProvider()) .UseSecurityDataProvider(new MemoryDataProvider(DatabaseStorage.CreateEmpty())) .UseSearchEngine(new InMemorySearchEngine()) .UseAccessProvider(new DesktopAccessProvider()) .UseElevatedModificationVisibilityRuleProvider(new ElevatedModificationVisibilityRule()) .UseCacheProvider(new EmptyCache()) .DisableNodeObservers() .StartIndexingEngine(false) .StartWorkflowEngine(false) .UseTraceCategories("Test", "Web", "System"); using (Repository.Start(repoBuilder)) { Assert.IsFalse(Providers.Instance.NodeObservers.Any()); } }
static void Main(string[] args) { IConfiguration config = new ConfigurationBuilder() .AddJsonFile("appsettings.json", true, true) .Build(); var builder = new RepositoryBuilder() .SetConsole(Console.Out) .UseLogger(new SnFileSystemEventLogger()) .UseTracer(new SnFileSystemTracer()) .UseConfiguration(config) .UseDataProvider(new MsSqlDataProvider()) .UseSecurityDataProvider( new EFCSecurityDataProvider(connectionString: ConnectionStrings.ConnectionString)) .UseLucene29LocalSearchEngine($"{Environment.CurrentDirectory}\\App_Data\\LocalIndex") as RepositoryBuilder; new Installer(builder) .InstallSenseNet(); }
internal static RepositoryBuilder GetRepositoryBuilder(IConfiguration configuration, IHostEnvironment environment) { // assemble a SQL-specific repository var repositoryBuilder = new RepositoryBuilder() .UseConfiguration(configuration) .UseLogger(new SnFileSystemEventLogger()) .UseTracer(new SnFileSystemTracer()) .UseAccessProvider(new UserAccessProvider()) .UseDataProvider(new MsSqlDataProvider()) .UseSecurityDataProvider(new EFCSecurityDataProvider(connectionString: ConnectionStrings.ConnectionString)) .UseLucene29LocalSearchEngine(Path.Combine(Environment.CurrentDirectory, "App_Data", "LocalIndex")) .StartWorkflowEngine(false) .UseTraceCategories("Event", "Custom", "System") as RepositoryBuilder; Providers.Instance.PropertyCollector = new EventPropertyCollector(); return(repositoryBuilder); }
public void save_saves_the_entity_returned_to_it_by_on_entity_saving() { var sut = new RepositoryBuilder() .WithOnEntitySaving((e, c) => new TestEntity { Id = 42, Column1 = "replacement" }) .Build(); sut .Save( new TestEntity { Id = 42, Column1 = "original" }); var result = sut.Get(42); Assert.NotNull(result); Assert.Equal("replacement", result.Column1); }
public void save_passes_entities_through_to_subclass_after_save() { var sut = new RepositoryBuilder() .WithOnEntitySaved( (e, c) => { e.Column1 = "replacement"; return(e); }) .Build(); var result = sut .Save( new TestEntity { Column1 = "original" }); Assert.NotNull(result); Assert.Equal("replacement", result.Column1); }
/// <summary> /// 添加仓储配置 /// </summary> /// <typeparam name="TContext"></typeparam> /// <param name="server"><see cref="RepositoryBuilder"/></param> /// <param name="storeOptionsAction">仓储配置设置函数</param> /// <returns></returns> public static RepositoryBuilder AddIdentityRepository(this RepositoryBuilder builder, RepositoryOptions options) { builder.Service.AddScoped <RepositoryDbContext>(); //builder.Service.AddDbContext<RepositoryDbContext>(options.DbContextOptions); //添加仓储服务 builder.AddRepository <ClientRepository, Client>(); builder.AddRepository <ApiResourceRepository, ApiResource>(); builder.AddRepository <IdentityResourceRepository, IdentityResource>(); builder.AddRepository <PersistedGrantRepository, PersistedGrant>(); builder.AddRepository <IdentityTokenRepository, IdentityToken>(); //添加数据商店服务 builder.Service.AddTransient <IApiResourceRepositories, ApiResourceRepository>(); builder.Service.AddTransient <IClientRepositories, ClientRepository>(); builder.Service.AddTransient <IIdentityResourceRepositories, IdentityResourceRepository>(); builder.Service.AddTransient <IPersistedGrantRepositories, PersistedGrantRepository>(); return(builder); }
public void save_can_insert_new_entities(string column1, string column2) { var sut = new RepositoryBuilder() .Build(); var result = sut .Save( new TestEntity { Column1 = column1, Column2 = column2 }); Assert.NotNull(result.Id); var reload = sut.Get(result.Id.Value); Assert.NotNull(reload); Assert.Equal(result.Id, reload.Id); Assert.Equal(column1, reload.Column1); Assert.Equal(column2, reload.Column2); }
/// <summary> /// 添加支付应用服务 /// </summary> /// <param name="services"><see cref="IServiceCollection"/></param> /// <param name="builer"><see cref="RepositoryBuilder"/> 配置</param> /// <param name="storageName">Storage的名称</param> /// <returns></returns> public static IServiceCollection AddRepositoryStorage(this IServiceCollection services, Action <RepositoryBuilder> builer, string storageName = RepositoryStorage.DefaultName) { //配置差异对比服务 services.TryAddSingleton <IChangeDetector, ChangeDetector>(); services.TryAddSingleton <IChangeManager, ChangeManager>(); services.TryAddSingleton <IChangeManagerFactory, ChangeManagerFactory>(); services.AddMemoryCache(opt => { opt.ExpirationScanFrequency = TimeSpan.FromHours(2); }); //配置Orleans 的存储配置 services.TryAddSingleton <IGrainStorage>(sp => sp.GetServiceByName <IGrainStorage>(ProviderConstants.DEFAULT_STORAGE_PROVIDER_NAME)); services.AddSingletonNamedService <IGrainStorage, RepositoryStorage>(storageName); //对应实体的仓储配置 var builder = new RepositoryBuilder(services); builer.Invoke(builder); return(services); }
public void save_passes_entities_through_to_subclass_before_save() { var called = false; var sut = new RepositoryBuilder() .WithOnEntitySaving( (e, c) => { called = true; return(e); }) .Build(); sut .Save( new TestEntity { Column1 = "original" }); Assert.True(called); }
public void get_passes_entity_through_to_subclass() { var sut = new RepositoryBuilder() .WithOnEntityLoaded( (e, c) => { e.Column1 = "replacement"; return(e); }) .Build(); sut.Save( new TestEntity { Id = 42, Column1 = "original" }); var entity = sut.Get(42); Assert.Equal("replacement", entity.Column1); }
public void RepositoryStart_NodeObservers_EnableMore() { var repoBuilder = new RepositoryBuilder() .UseDataProvider(new InMemoryDataProvider()) .UseSecurityDataProvider(new MemoryDataProvider(DatabaseStorage.CreateEmpty())) .UseSearchEngine(new InMemorySearchEngine()) .UseAccessProvider(new DesktopAccessProvider()) .UseElevatedModificationVisibilityRuleProvider(new ElevatedModificationVisibilityRule()) .UseCacheProvider(new EmptyCache()) .DisableNodeObservers() .EnableNodeObservers(typeof(TestNodeObserver1), typeof(TestNodeObserver2)) .StartIndexingEngine(false) .StartWorkflowEngine(false) .UseTraceCategories("Test", "Web", "System"); using (Repository.Start(repoBuilder)) { Assert.AreEqual(2, Providers.Instance.NodeObservers.Length); Assert.IsTrue(Providers.Instance.NodeObservers.Any(no => no.GetType() == typeof(TestNodeObserver1))); Assert.IsTrue(Providers.Instance.NodeObservers.Any(no => no.GetType() == typeof(TestNodeObserver2))); } }
protected static RepositoryBuilder CreateRepositoryBuilderForTest(TestContext testContext, Action <IServiceCollection> modifyServices = null) { IServiceProvider services; var reusesRepository = (bool)(testContext.Properties["ReusesRepository"] ?? false); if (!reusesRepository || Providers.Instance == null) { services = CreateServiceProviderForTest(modifyServices: modifyServices); Providers.Instance = new Providers(services); } else { services = Providers.Instance.Services; } Cache.Reset(); Providers.Instance.ResetBlobProviders(new ConnectionStringOptions()); var builder = new RepositoryBuilder(services) .UseLogger(new DebugWriteLoggerAdapter()) .UseTracer(new SnDebugViewTracer()) .UseAccessProvider(new DesktopAccessProvider()) .UseInitialData(GetInitialData()) .UseTestingDataProvider(services.GetRequiredService <ITestingDataProvider>()) .UseBlobProviderStore(services.GetRequiredService <IBlobProviderStore>()) .UseBlobMetaDataProvider(services.GetRequiredService <IBlobStorageMetaDataProvider>()) .UseBlobProviderSelector(services.GetRequiredService <IBlobProviderSelector>()) .UseStatisticalDataProvider(services.GetRequiredService <IStatisticalDataProvider>()) .UseSearchEngine(new InMemorySearchEngine(GetInitialIndex())) .StartWorkflowEngine(false) .DisableNodeObservers() .EnableNodeObservers(typeof(SettingsCache)) .UseTraceCategories("Test", "Event", "Custom") as RepositoryBuilder; ContentTypeManager.Reset(); return(builder); }
public RepositoryBuilder CreateRepositoryBuilder() { Providers.Instance.ResetBlobProviders(); var builder = new RepositoryBuilder(); OnBeforeGettingRepositoryBuilder(builder); var dataProvider = GetDataProvider(); builder .UseLogger(new DebugWriteLoggerAdapter()) .UseTracer(new SnDebugViewTracer()) .UseDataProvider(dataProvider) .UseInitialData(Initializer.InitialData) .UseTestingDataProviderExtension(GetTestingDataProviderExtension()) .UseSharedLockDataProviderExtension(GetSharedLockDataProviderExtension()) .UseExclusiveLockDataProviderExtension(GetExclusiveLockDataProviderExtension()) .AddBlobProviders(GetBlobProviders()) // extension for platforms .UseBlobMetaDataProvider(GetBlobMetaDataProvider(dataProvider)) .UseBlobProviderSelector(GetBlobProviderSelector()) .UseAccessTokenDataProviderExtension(GetAccessTokenDataProviderExtension()) .UsePackagingDataProviderExtension(GetPackagingDataProviderExtension()) .UseStatisticalDataProvider(GetStatisticalDataProvider()) .UseSearchEngine(GetSearchEngine()) .UseSecurityDataProvider(GetSecurityDataProvider(dataProvider)) .UseSecurityMessageProvider(new DefaultMessageProvider(new MessageSenderManager())) .UseElevatedModificationVisibilityRuleProvider(new ElevatedModificationVisibilityRule()) .StartWorkflowEngine(false) .DisableNodeObservers() .EnableNodeObservers(typeof(SettingsCache)) .UseTraceCategories("Test", "Event", "Custom"); Providers.Instance.PropertyCollector = new EventPropertyCollector(); OnAfterGettingRepositoryBuilder(builder); return(builder); }
public RepositoryBuilder CreateRepositoryBuilder() { var serviceCollection = new ServiceCollection(); BuildServices(AppConfig, serviceCollection); var services = serviceCollection.BuildServiceProvider(); Providers.Instance = new Providers(services); var connectionString = AppConfig.GetConnectionString("SnCrMsSql"); Providers.Instance.ResetBlobProviders(new ConnectionStringOptions { Repository = connectionString }); var builder = new RepositoryBuilder(services); OnBeforeGettingRepositoryBuilder(builder); builder .UseLogger(new DebugWriteLoggerAdapter()) .UseTracer(new SnDebugViewTracer()) //.UseAccessProvider(new DesktopAccessProvider()) .UseInitialData(Initializer.InitialData) .UseTestingDataProvider(services.GetRequiredService <ITestingDataProvider>()) .UseBlobProviderStore(services.GetRequiredService <IBlobProviderStore>()) .UseBlobMetaDataProvider(services.GetRequiredService <IBlobStorageMetaDataProvider>()) .UseBlobProviderSelector(services.GetRequiredService <IBlobProviderSelector>()) .UseStatisticalDataProvider(services.GetRequiredService <IStatisticalDataProvider>()) .UseSearchEngine(GetSearchEngine()) .StartWorkflowEngine(false) .DisableNodeObservers() .EnableNodeObservers(typeof(SettingsCache)) .UseTraceCategories("Test", "Event", "Custom"); OnAfterGettingRepositoryBuilder(builder); return(builder); }
static void Main(string[] args) { IRepositoryBuilder repositoryBuilder = new RepositoryBuilder(); var repository = repositoryBuilder .SetSource(new CollectionRepositorySource <Song>()) .Build <ISongRepository>(); repository.Create(new Song { Id = 0, Name = "Agata Resx - Download my source code" }); repository.Create(new Song { Id = 1, Name = "Agata Resx - Comment me" }); repository.Create(new Song { Id = 2, Name = "Agata Resx - Star" }); repository.Create(new Song { Id = 3, Name = "Agata Resx - Men" }); var songs = repository.SelectPage(1, 2); }
private void StartDataStore(string destination) { RepositoryHooks hooks = new RepositoryHooks { OnDataAllocated = OnDataAllocated, OnDataVerified = OnDataVerified, OnBlockWritten = OnBlockWritten, OnPieceAccepted = OnPieceAccepted, OnPieceRejected = OnPieceRejected }; DataStore = new RepositoryBuilder() .WithHash(Hash) .WithDestination(Path.Combine(destination, Hash.ToString())) .WithPipeline(Pipeline) .WithFiles(Files) .WithMemory(Memory.AsDataStore()) .WithBufferSize(256 * 1024) .Build(hooks); DataStore.Start(); }
public void RepositoryStart_NodeObservers_DisableOne() { var repoBuilder = new RepositoryBuilder() .UseDataProvider(new InMemoryDataProvider()) .UseSecurityDataProvider(new MemoryDataProvider(DatabaseStorage.CreateEmpty())) .UseSearchEngine(new InMemorySearchEngine()) .UseAccessProvider(new DesktopAccessProvider()) .UseElevatedModificationVisibilityRuleProvider(new ElevatedModificationVisibilityRule()) .UseCacheProvider(new EmptyCache()) .DisableNodeObservers(typeof(TestNodeObserver1)) .StartIndexingEngine(false) .StartWorkflowEngine(false) .UseTraceCategories("Test", "Web", "System"); using (Repository.Start(repoBuilder)) { Assert.IsFalse(Providers.Instance.NodeObservers.Any(no => no.GetType() == typeof(TestNodeObserver1))); //TODO: currently this does not work, because observers are enabled/disabled globally. // Itt will, when we move to a per-thread environment in tests. //Assert.IsTrue(Providers.Instance.NodeObservers.Any(no => no.GetType() == typeof(TestNodeObserver2))); } }
public RepositoryBuilder BuildProviders() { // set provider instances for legacy code (task manager, preview provider) Services.AddSenseNetProviderInstances(); var components = Services.GetServices <ISnComponent>().ToArray(); var eventProcessors = Services.GetServices <IEventProcessor>().ToArray(); var repositoryBuilder = new RepositoryBuilder(Services) .UseLogger(new SnFileSystemEventLogger()) .UseTracer(new SnFileSystemTracer()) .UseComponent(components) .UseAccessProvider(new UserAccessProvider()) .StartWorkflowEngine(false) .UseEventDistributor(new EventDistributor()) .AddAsyncEventProcessors(eventProcessors) .UseTraceCategories("Event", "Custom", "System", "Security") as RepositoryBuilder; // hook for developers to modify the repository builder before start BuildRepository?.Invoke(repositoryBuilder, Services); return(repositoryBuilder); }
private Repository CreateNew() { var builder = new RepositoryBuilder(); builder.ReadEnvironment(); builder.FindGitDir(Path); return builder.Build(); }
protected Repository CreateDummyRepository() { var builder = new RepositoryBuilder(); builder.SetBare(); builder.SetWorkTree(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString())); builder.Setup(); return builder.Build(); }