public FileSystem() { FileSystemEnumerationOptions = new EnumerationOptions() { AttributesToSkip = 0, ReturnSpecialDirectories = false, IgnoreInaccessible = true }; IsShowingFileExtensions = true; FileSystemItemFactory = (fileSystemInfo, parent, isDrive) => new FileSystemItemModel(fileSystemInfo, parent, isDrive); FileFactory = (fileInfo, parent) => new File(fileInfo, parent); DirectoryFactory = (directoryInfo, parent) => new Directory(directoryInfo, parent); DriveFactory = (driveInfo) => new Drive(driveInfo, FileSystemMount); InternalDrives = new ObservableCollection <DriveInfo>(); Drives = new ReadOnlyObservableCollection <DriveInfo>(InternalDrives); InternalFileSystemRoot = new ObservableCollection <IFileSystemItemModel>(); FileSystemRoot = new ReadOnlyObservableCollection <IFileSystemItemModel>(InternalFileSystemRoot); FileSystemRootChangeObservers = new Dictionary <string, FileSystemWatcher>(); Index = new Dictionary <string, IFileSystemItemModel>(); HiddenIndex = new Dictionary <string, IFileSystemItemModel>(); SystemIndex = new Dictionary <string, IFileSystemItemModel>(); FileSystemMount = DirectoryFactory.Invoke(null, null); SyncObject = new object(); Application.Current.Dispatcher.Invoke(() => { BindingOperations.EnableCollectionSynchronization(InternalDrives, SyncObject); BindingOperations.EnableCollectionSynchronization(Drives, SyncObject); BindingOperations.EnableCollectionSynchronization(InternalFileSystemRoot, SyncObject); BindingOperations.EnableCollectionSynchronization(FileSystemRoot, SyncObject); }, System.Windows.Threading.DispatcherPriority.Normal); }
public async Task OneLogWrittenInFile_When_OneLogExists() { // Arrange var logs = LogFactory.Create(1); _logRepositoryMock.Setup(x => x.GetAllAsync()).Returns(Task.FromResult(logs)); _directoryProvider.Setup(x => x.DoesDirectoryExists(It.IsAny <string>())).Returns(true); _dateTimeProvider.Setup(x => x.GetCurrentTime()).Returns(DateTime.Now); _pathProvider.Setup(x => x.Combine(It.IsAny <string>(), It.IsAny <string>())).Returns((string path1, string filePath) => Path.Combine(path1, filePath)); _fileProvider.Setup(x => x.WriteAllText(It.IsAny <string>(), It.IsAny <string>())).Callback((string filePath, string content) => File.WriteAllText(filePath, content)); string dumpFileLocation = DirectoryFactory.CreateTestDirectory(); var exceptionLogDumpCreator = new DistributeLogDumpCreator( _logRepositoryMock.Object, _dateTimeProvider.Object, _fileProvider.Object, _directoryProvider.Object, _pathProvider.Object, _consoleProvider.Object, _reflectionProvider.Object); // Act string dumpFile = await exceptionLogDumpCreator.CreateDumpAsync(dumpFileLocation); // Assert string dumpFileContent = File.ReadAllText(dumpFile); string expectedContent = GetExpectedDumpFileContent(logs); Assert.That(dumpFileContent, Is.EqualTo(expectedContent)); }
public void Then_Gets_Same_Directory(DirectoryFactory directoryFactory) { var directory1 = directoryFactory.GetDirectory(); var directory2 = directoryFactory.GetDirectory(); directory1.Should().BeSameAs(directory2); }
private void OnFileSystemItemCreated(object sender, FileSystemEventArgs e) { if (System.IO.Directory.Exists(e.FullPath)) { var createdDirectoryInfo = new DirectoryInfo(e.FullPath); if (!Index.TryGetValue(createdDirectoryInfo.Parent.FullName, out IFileSystemItemModel parentFileSystemItem) || parentFileSystemItem is not IDirectory parentDirectoryItem) { // File system item is not indexed/never visited before. // Changes will be visible the first time this folder or its child items are indexed/visited return; } var createdDirectoryItem = DirectoryFactory.Invoke(createdDirectoryInfo, parentDirectoryItem); AddNewFileSystemInfo(createdDirectoryItem, parentDirectoryItem); } else if (System.IO.File.Exists(e.FullPath)) { var createdFileInfo = new FileInfo(e.FullPath); if (!Index.TryGetValue(createdFileInfo.DirectoryName, out IFileSystemItemModel parentFileSystemItem) || parentFileSystemItem is not IDirectory parentDirectoryItem) { // File system item is not indexed/never visited before. // Changes will be visible the first time this folder or its child items are indexed/visited return; } var createdFileItem = FileFactory.Invoke(createdFileInfo, parentDirectoryItem); AddNewFileSystemInfo(createdFileItem, parentDirectoryItem); } }
public PartitionedIndexStorage(DirectoryFactory directoryFactory, FileSystemAbstraction fileSystem, File rootFolder) { this._fileSystem = fileSystem; this._folderLayout = new IndexFolderLayout(rootFolder); this._directoryFactory = directoryFactory; this._failureStorage = new FailureStorage(fileSystem, _folderLayout); }
public async Task UniqueTimestampFileNameGenerated_When_NoLogExists() { // Arrange var logs = LogFactory.Create(2); _logRepositoryMock.Setup(x => x.GetAllAsync()).Returns(Task.FromResult(logs)); _directoryProvider.Setup(x => x.DoesDirectoryExists(It.IsAny <string>())).Returns(true); _dateTimeProvider.Setup(x => x.GetCurrentTime()).Returns(new DateTime(1989, 10, 28, 21, 21, 5, 999)); _pathProvider.Setup(x => x.Combine(It.IsAny <string>(), It.IsAny <string>())).Returns((string path1, string filePath) => Path.Combine(path1, filePath)); _fileProvider.Setup(x => x.WriteAllText(It.IsAny <string>(), It.IsAny <string>())).Callback((string filePath, string content) => File.WriteAllText(filePath, content)); string dumpFileLocation = DirectoryFactory.CreateTestDirectory(); var exceptionLogDumpCreator = new DistributeLogDumpCreator( _logRepositoryMock.Object, _dateTimeProvider.Object, _fileProvider.Object, _directoryProvider.Object, _pathProvider.Object, _consoleProvider.Object, _reflectionProvider.Object); // Act string dumpFile = await exceptionLogDumpCreator.CreateDumpAsync(dumpFileLocation); // Assert string expectedDumpFileName = "10-28-1989-09-21-05-9990.txt"; Assert.That(new FileInfo(dumpFile).Name, Is.EqualTo(expectedDumpFileName)); }
public LuceneIndexProviderAnonymousInnerClass(LuceneSchemaIndexCorruptionTest outerInstance, EphemeralFileSystemAbstraction fs, DirectoryFactory directoryFactory, UnknownType defaultDirectoryStructure, IndexProvider.Monitor monitor, Config defaults, long faultyIndexId, Exception error, AtomicReference <FaultyIndexStorageFactory> reference) : base(fs, directoryFactory, defaultDirectoryStructure, monitor, defaults, OperationalMode.single) { this.outerInstance = outerInstance; this._faultyIndexId = faultyIndexId; this._error = error; this._directoryFactory = directoryFactory; this._reference = reference; }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @BeforeEach void initLuceneResources() throws Exception //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: internal virtual void InitLuceneResources() { _dirFactory = new Org.Neo4j.Kernel.Api.Impl.Index.storage.DirectoryFactory_InMemoryDirectoryFactory(); Directory dir = _dirFactory.open(_testDir.directory("test")); _writer = new IndexWriter(dir, IndexWriterConfigs.standard()); _searcherManager = new SearcherManager(_writer, true, new SearcherFactory()); }
private LuceneIndexProvider NewFaultyIndexProvider(long faultyIndexId, Exception error) { DirectoryFactory directoryFactory = mock(typeof(DirectoryFactory)); File indexRootFolder = _testDirectory.databaseDir(); AtomicReference <FaultyIndexStorageFactory> reference = new AtomicReference <FaultyIndexStorageFactory>(); return(new LuceneIndexProviderAnonymousInnerClass(this, _fs, directoryFactory, defaultDirectoryStructure(indexRootFolder), _monitor, Config.defaults(), faultyIndexId, error, reference)); }
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#: //ORIGINAL LINE: private WritableTestDatabaseIndex createTestLuceneIndex(org.neo4j.kernel.api.impl.index.storage.DirectoryFactory dirFactory, java.io.File folder) throws java.io.IOException private WritableTestDatabaseIndex CreateTestLuceneIndex(DirectoryFactory dirFactory, File folder) { PartitionedIndexStorage indexStorage = new PartitionedIndexStorage(dirFactory, _fileSystem, folder); WritableTestDatabaseIndex index = new WritableTestDatabaseIndex(indexStorage); index.Create(); index.open(); return(index); }
public void Setup() { var mockDataContext = new Mock <ICoursesDataContext>(); mockDataContext .Setup(context => context.Standards) .ReturnsDbSet(_standards); var directoryFactory = new DirectoryFactory(); var builder = new CoursesIndexBuilder(mockDataContext.Object, directoryFactory); builder.Build(); _searchManager = new CoursesSearchManager(directoryFactory); }
private bool TryRealizeChildren(IEnumerable <IDirectory> treeLevelDirectories, CancellationToken cancellationToken, int levelCount, bool isSortingEnabled) { if (levelCount < 1) { throw new ArgumentOutOfRangeException("Level count can't be smaller than 1"); } bool hasRealizedItem = false; if (treeLevelDirectories == null) { return(false); } cancellationToken.ThrowIfCancellationRequested(); int remainingLevelCount = levelCount; var breadthFirstQueue = new List <IDirectory>(); foreach (IDirectory parentDirectory in treeLevelDirectories.Where(directory => !directory.IsRealized)) { foreach (FileSystemInfo childInfo in parentDirectory.Info.EnumerateFileSystemInfos("*", FileSystemEnumerationOptions)) { IFileSystemItemModel childItem; if (childInfo is DirectoryInfo directory) { childItem = DirectoryFactory.Invoke(directory, parentDirectory); breadthFirstQueue.Add((IDirectory)childItem); } else { childItem = FileFactory.Invoke(childInfo as FileInfo, parentDirectory); } IndexFileSystemItem(childItem); parentDirectory.ChildFileSystemItems.Add(childItem); hasRealizedItem = true; } if (isSortingEnabled) { parentDirectory.Sort(); } } if (--remainingLevelCount > 0) { cancellationToken.ThrowIfCancellationRequested(); TryRealizeChildren(breadthFirstQueue, cancellationToken, remainingLevelCount, isSortingEnabled); } return(hasRealizedItem); }
public static ICollection <ApplicationUninstallerEntry> GetApplicationsFromDirectories( IEnumerable <ApplicationUninstallerEntry> allUninstallers, ICollection <DirectoryInfo> results) { var output = new List <ApplicationUninstallerEntry>(); var processed = new List <DirectoryInfo>(); foreach (var dir in results.Distinct(PathTools.PathsEqual).OrderBy(x => x.FullName)) { if (processed.Any(x => x.FullName.Contains(dir.FullName, StringComparison.InvariantCultureIgnoreCase))) { continue; } processed.Add(dir); } var exceptions = allUninstallers.Where(x => x.InstallLocation != null).ToList(); var infoAdder = new InfoAdderManager(); foreach (var dir in processed) { var items = exceptions.Where( x => x.InstallLocation.Contains(dir.FullName, StringComparison.InvariantCultureIgnoreCase)) .ToList(); if (items.Count > 0) { output.AddRange(items); continue; } var res = DirectoryFactory.TryCreateFromDirectory(dir, exceptions).ToList(); if (res.Count == 0) { MessageBox.Show( string.Format(Localisable.Uninstaller_GetApplicationsFromDirectories_NothingFound_Message, dir.FullName), Localisable.Uninstaller_GetApplicationsFromDirectories_NothingFound_Title, MessageBoxButtons.OK, MessageBoxIcon.Warning); continue; } foreach (var result in res) { infoAdder.AddMissingInformation(result); output.Add(result); } } return(output); }
public void ReturnTrue_When_FolderExists() { // Arrange string newFolder = DirectoryFactory.CreateTestDirectory(); var directoryProvider = new DirectoryProvider(); // Act bool doesFolderExists = directoryProvider.DoesDirectoryExists(newFolder); // Assert Assert.That(doesFolderExists, Is.True); // Clean-up Directory.Delete(newFolder); }
public void ReturnCorrectFilePaths() { // Arrange string newFolder = DirectoryFactory.CreateTestDirectory(); string firstFile = FileFactory.CreateTestFile(newFolder, null, string.Empty); string secondFile = FileFactory.CreateTestFile(newFolder, null, string.Empty); var expectedCollection = new[] { firstFile, secondFile }; var directoryProvider = new DirectoryProvider(); // Act var files = directoryProvider.GetFiles(newFolder); // Assert Assert.That(files, Is.EquivalentTo(expectedCollection)); }
public void Then_Adds_Doc_For_Each_Standard( List <Standard> standards, Mock <ICoursesDataContext> mockDataContext, DirectoryFactory directoryFactory) { mockDataContext .Setup(context => context.Standards) .ReturnsDbSet(standards); var builder = new CoursesIndexBuilder(mockDataContext.Object, directoryFactory); builder.Build(); var directory = directoryFactory.GetDirectory(); var files = directory.ListAll(); files.Length.Should().NotBe(0); }
private bool RealizeFromRoot(int levelCount, CancellationToken cancellationToken, bool isSortingEnabled) { bool hasRealizedItem = false; var nextLevelBreadthFirstQueue = new Queue <IDirectory>(InternalFileSystemRoot .OfType <IDrive>() .Where(rootItem => rootItem.IsReady)); int remainingLevels = levelCount; while (remainingLevels > 0 && nextLevelBreadthFirstQueue.Any()) { remainingLevels--; var currentLevelBreadthFirstQueue = new Queue <IDirectory>(nextLevelBreadthFirstQueue); nextLevelBreadthFirstQueue.Clear(); while (currentLevelBreadthFirstQueue.TryDequeue(out IDirectory parentDirectory)) { parentDirectory.ChildFileSystemItems.Clear(); foreach (FileSystemInfo childInfo in parentDirectory.Info.EnumerateFileSystemInfos("*", FileSystemEnumerationOptions)) { IFileSystemItemModel childItem; if (childInfo is DirectoryInfo directory) { childItem = DirectoryFactory.Invoke(directory, parentDirectory); nextLevelBreadthFirstQueue.Enqueue((IDirectory)childItem); } else { childItem = FileFactory.Invoke(childInfo as FileInfo, parentDirectory); } IndexFileSystemItem(childItem); parentDirectory.ChildFileSystemItems.Add(childItem); hasRealizedItem = true; } if (isSortingEnabled) { parentDirectory.Sort(); } } cancellationToken.ThrowIfCancellationRequested(); } return(hasRealizedItem); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); DirectoryFactory.Register("EasyDemo", new StaticDirectory(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "servicedemo.config"), "EasyDemo")); var isRegsiterToRegiserCenter = StringHelper.ToInt32(ConfigurationManager.AppSettings["isRegsiterToRegiserCenter"], 1); if (isRegsiterToRegiserCenter == 1) { string registerUrl = ConfigurationManager.AppSettings["registerUrl"]; string redisUrl = ConfigurationManager.AppSettings["redisUrl"]; int databaseIndex = int.Parse(ConfigurationManager.AppSettings["databaseIndex"]); var builder = new RedisDirectoryBuilder(registerUrl, redisUrl); builder.Build(new MySelfInfo() { Description = "Demo站点", Directory = "DemoWebSite", Status = 1, Weight = 10, Url = string.Format("http://{0}", IpHelper.InternetIp4()), Ip = string.Format("{0}:{1}", IpHelper.InternetIp4(), 80) }, new string[1] { "ServiceDemo" }, new string[0]); string monitorUrl = ConfigurationManager.AppSettings["monitorUrl"]; MonitorManager.RegisterSend(new HttpSendCollectorData(monitorUrl)); } //if (ConfigurationManager.AppSettings["remoteLog"] == "true") //{ // LogManager.Register(new RemoteLogger() { Url = "http://101.200.124.233:3100/logH5" }); //} //string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EasyDemo.config"); //Easy.Rpc.directory.DirectoryFactory.Register("EasyDemo", new StaticDirectory(path, "EasyDemo")); }
public virtual Directory CreateFileSystemLuceneDirectory(string folderName) { var combinedPath = Path.Combine("App_Data/TEMP", "ExamineIndexes", folderName); var baseDirectory = AppContext.BaseDirectory; var currentPath = Path.Combine(AppContext.BaseDirectory, combinedPath); var dirInfo = new DirectoryInfo(currentPath); if (!dirInfo.Exists) { System.IO.Directory.CreateDirectory(dirInfo.FullName); } string configuredDirectoryFactory = _configuration["Novicell.Examine.LuceneDirectoryFactory"]; if (!string.IsNullOrWhiteSpace(configuredDirectoryFactory)) { /* TODO: Check with Mikkel if is better way for TypeFinder */ var factoryType = ExamineTypeFinder.GetTypeByName(configuredDirectoryFactory); if (factoryType == null) { throw new NullReferenceException("No directory type found for value: " + configuredDirectoryFactory); } var directoryFactory = (IDirectoryFactory)this.Resolve <IDirectoryFactory>(factoryType); return(directoryFactory.CreateDirectory(dirInfo, true)); } //no dir factory, just create a normal fs directory var luceneDir = new SimpleFSDirectory(dirInfo); //we want to tell examine to use a different fs lock instead of the default NativeFSFileLock which could cause problems if the appdomain //terminates and in some rare cases would only allow unlocking of the file if IIS is forcefully terminated. Instead we'll rely on the simplefslock //which simply checks the existence of the lock file // The full syntax of this is: new NoPrefixSimpleFsLockFactory(dirInfo) // however, we are setting the DefaultLockFactory in startup so we'll use that instead since it can be managed globally. luceneDir.SetLockFactory(DirectoryFactory.DefaultLockFactory(dirInfo)); return(luceneDir); }
public void And_Called_Multiple_Times_Then_No_Duplicates( List <Standard> standards, Mock <ICoursesDataContext> mockDataContext, DirectoryFactory directoryFactory) { var directory = directoryFactory.GetDirectory(); mockDataContext .Setup(context => context.Standards) .ReturnsDbSet(standards); var builder = new CoursesIndexBuilder(mockDataContext.Object, directoryFactory); // act builder.Build(); var firstFiles = directory.ListAll(); builder.Build(); var secondFiles = directory.ListAll(); firstFiles.Length.Should().NotBe(0); secondFiles.Length.Should().Be(firstFiles.Length); }
/// <summary> /// Creates a file system based Lucene <see cref="Lucene.Net.Store.Directory"/> with the correct locking guidelines for Umbraco /// </summary> /// <param name="folderName"> /// The folder name to store the index (single word, not a fully qualified folder) (i.e. Internal) /// </param> /// <returns></returns> public virtual Lucene.Net.Store.Directory CreateFileSystemLuceneDirectory(string folderName) { var dirInfo = new DirectoryInfo(Path.Combine(IOHelper.MapPath(SystemDirectories.Data), "TEMP", "ExamineIndexes", folderName)); if (!dirInfo.Exists) { System.IO.Directory.CreateDirectory(dirInfo.FullName); } //check if there's a configured directory factory, if so create it and use that to create the lucene dir var configuredDirectoryFactory = ConfigurationManager.AppSettings["Umbraco.Examine.LuceneDirectoryFactory"]; if (!configuredDirectoryFactory.IsNullOrWhiteSpace()) { //this should be a fully qualified type var factoryType = TypeFinder.GetTypeByName(configuredDirectoryFactory); if (factoryType == null) { throw new NullReferenceException("No directory type found for value: " + configuredDirectoryFactory); } var directoryFactory = (IDirectoryFactory)Activator.CreateInstance(factoryType); return(directoryFactory.CreateDirectory(dirInfo)); } //no dir factory, just create a normal fs directory var luceneDir = new SimpleFSDirectory(dirInfo); //we want to tell examine to use a different fs lock instead of the default NativeFSFileLock which could cause problems if the appdomain //terminates and in some rare cases would only allow unlocking of the file if IIS is forcefully terminated. Instead we'll rely on the simplefslock //which simply checks the existence of the lock file // The full syntax of this is: new NoPrefixSimpleFsLockFactory(dirInfo) // however, we are setting the DefaultLockFactory in startup so we'll use that instead since it can be managed globally. luceneDir.SetLockFactory(DirectoryFactory.DefaultLockFactory(dirInfo)); return(luceneDir); }
internal FaultyIndexStorageFactory(LuceneSchemaIndexCorruptionTest outerInstance, long faultyIndexId, Exception error, DirectoryFactory directoryFactory, IndexDirectoryStructure directoryStructure) : base(directoryFactory, outerInstance.fs, directoryStructure) { this._outerInstance = outerInstance; this.FaultyIndexId = faultyIndexId; this.Error = error; }
public IndexStorageFactory(DirectoryFactory dirFactory, FileSystemAbstraction fileSystem, IndexDirectoryStructure structure) { this._dirFactory = dirFactory; this._fileSystem = fileSystem; this._structure = structure; }
private async Task ExecuteBuild() { _chalk.Default("\nBuilding Solution...\n"); var log = new StringBuilder(); void OutputData(object sender, string args) => log.AppendLine(args); var testCodeBuild = new CppBuildExecutor( MuTestSettings, string.Format(Context.TestSolution.FullName, 0), _cppClass.Target) { Configuration = _options.Configuration, EnableLogging = _options.EnableDiagnostics, IntDir = string.Format(Context.IntDir, 0), IntermediateOutputPath = string.Format(Context.IntermediateOutputPath, 0), OutDir = string.Format(Context.OutDir, 0), OutputPath = string.Format(Context.OutputPath, 0), Platform = _options.Platform, QuietWithSymbols = true }; if (!_options.IncludeBuildEvents) { string.Format(Context.TestProject.FullName, 0).RemoveBuildEvents(); } testCodeBuild.OutputDataReceived += OutputData; testCodeBuild.BeforeMsBuildExecuted += (sender, args) => { _chalk.Yellow($"\nRunning MSBuild with {args}\n"); }; await testCodeBuild.ExecuteBuild(); testCodeBuild.OutputDataReceived -= OutputData; if (testCodeBuild.LastBuildStatus == BuildExecutionStatus.Failed && !_options.InIsolation) { _chalk.Yellow("\nBuild Failed...Preparing new solution files\n"); DirectoryFactory.DeleteTestFiles(Context); Context = DirectoryFactory.PrepareSolutionFiles(_cppClass); testCodeBuild = new CppBuildExecutor( MuTestSettings, string.Format(Context.TestSolution.FullName, 0), _cppClass.Target) { Configuration = _options.Configuration, EnableLogging = _options.EnableDiagnostics, IntDir = string.Format(Context.IntDir, 0), IntermediateOutputPath = string.Format(Context.IntermediateOutputPath, 0), OutDir = string.Format(Context.OutDir, 0), OutputPath = string.Format(Context.OutputPath, 0), Platform = _options.Platform, QuietWithSymbols = true }; testCodeBuild.BeforeMsBuildExecuted += (sender, args) => { _chalk.Yellow($"\nRunning MSBuild with {args}\n"); }; await testCodeBuild.ExecuteBuild(); } if (testCodeBuild.LastBuildStatus == BuildExecutionStatus.Failed) { _chalk.Yellow("\nBuild Failed...Taking Source Code Backup\n"); _options.ConcurrentTestRunners = 1; DirectoryFactory.DeleteTestFiles(Context); Context = DirectoryFactory.TakingSourceCodeBackup(_cppClass); testCodeBuild = new CppBuildExecutor( MuTestSettings, Context.TestSolution.FullName, _cppClass.Target) { Configuration = _options.Configuration, EnableLogging = _options.EnableDiagnostics, IntDir = Context.IntDir, IntermediateOutputPath = Context.IntermediateOutputPath, OutDir = Context.OutDir, OutputPath = Context.OutputPath, Platform = _options.Platform, QuietWithSymbols = true }; testCodeBuild.BeforeMsBuildExecuted += (sender, args) => { _chalk.Yellow($"\nRunning MSBuild with {args}\n"); }; await testCodeBuild.ExecuteBuild(); } if (testCodeBuild.LastBuildStatus == BuildExecutionStatus.Failed) { throw new MuTestFailingBuildException(log.ToString()); } _chalk.Green("\nBuild Succeeded!"); }
public void UninstallFromDirectory(IEnumerable <ApplicationUninstallerEntry> allUninstallers) { if (!TryGetUninstallLock()) { return; } var listRefreshNeeded = false; var applicationUninstallerEntries = allUninstallers as IList <ApplicationUninstallerEntry> ?? allUninstallers.ToList(); try { var dialog = new FolderBrowserDialog { RootFolder = Environment.SpecialFolder.Desktop, Description = Localisable.UninstallFromDirectory_FolderBrowse }; if (dialog.ShowDialog(MessageBoxes.DefaultOwner) != DialogResult.OK) { return; } var items = new List <ApplicationUninstallerEntry>(); LoadingDialog.ShowDialog(MessageBoxes.DefaultOwner, Localisable.UninstallFromDirectory_ScanningTitle, _ => { items.AddRange(DirectoryFactory.TryCreateFromDirectory( new DirectoryInfo(dialog.SelectedPath), null, new string[] { })); }); if (items.Count == 0) { items.AddRange(applicationUninstallerEntries .Where(x => PathTools.PathsEqual(dialog.SelectedPath, x.InstallLocation))); } if (items.Count == 0) { MessageBoxes.UninstallFromDirectoryNothingFound(); } else { foreach (var item in items.ToList()) { if (item.UninstallPossible && item.UninstallerKind != UninstallerType.SimpleDelete && MessageBoxes.UninstallFromDirectoryUninstallerFound(item.DisplayName, item.UninstallString)) { item.RunUninstaller(false, Settings.Default.AdvancedSimulate).WaitForExit(60000); items.Remove(item); listRefreshNeeded = true; } else { var found = applicationUninstallerEntries.Where( x => PathTools.PathsEqual(item.InstallLocation, x.InstallLocation)).ToList(); if (!found.Any()) { continue; } items.Remove(item); foreach (var entry in found) { if (entry.UninstallPossible && entry.UninstallerKind != UninstallerType.SimpleDelete && MessageBoxes.UninstallFromDirectoryUninstallerFound(entry.DisplayName, entry.UninstallString)) { try { item.RunUninstaller(false, Settings.Default.AdvancedSimulate).WaitForExit(60000); } catch (Exception ex) { PremadeDialogs.GenericError(ex); } listRefreshNeeded = true; } else { items.Add(entry); } } } } AdvancedUninstall(items, applicationUninstallerEntries.Where( x => !items.Any(y => PathTools.PathsEqual(y.InstallLocation, x.InstallLocation)))); } } finally { ReleaseUninstallLock(); _lockApplication(false); if (listRefreshNeeded) { _initiateListRefresh(); } } }
internal FulltextIndexProvider(IndexProviderDescriptor descriptor, IndexDirectoryStructure.Factory directoryStructureFactory, FileSystemAbstraction fileSystem, Config config, TokenHolders tokenHolders, DirectoryFactory directoryFactory, OperationalMode operationalMode, JobScheduler scheduler, AuxiliaryTransactionStateManager auxiliaryTransactionStateManager, Log log) : base(descriptor, directoryStructureFactory) { this._fileSystem = fileSystem; this._config = config; this._tokenHolders = tokenHolders; this._operationalMode = operationalMode; this._auxiliaryTransactionStateManager = auxiliaryTransactionStateManager; this._log = log; _defaultAnalyzerName = config.Get(FulltextConfig.FulltextDefaultAnalyzer); _defaultEventuallyConsistentSetting = Convert.ToString(config.Get(FulltextConfig.EventuallyConsistent)); _indexUpdateSink = new IndexUpdateSink(scheduler, config.Get(FulltextConfig.EventuallyConsistentIndexUpdateQueueMaxLength)); _openOnlineAccessors = new ConcurrentDictionary <StoreIndexDescriptor, FulltextIndexAccessor>(); _indexStorageFactory = BuildIndexStorageFactory(fileSystem, directoryFactory); }
private IndexStorageFactory BuildIndexStorageFactory(FileSystemAbstraction fileSystem, DirectoryFactory directoryFactory) { return(new IndexStorageFactory(directoryFactory, fileSystem, DirectoryStructure())); }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes: //ORIGINAL LINE: @Before public void before() public virtual void Before() { _directoryFactory = new Org.Neo4j.Kernel.Api.Impl.Index.storage.DirectoryFactory_InMemoryDirectoryFactory(); }
public LuceneIndexProviderAnonymousInnerClass(KernelExtensionFactoryAnonymousInnerClass outerInstance, UnknownType get, DirectoryFactory directoryFactory, UnknownType defaultDirectoryStructure, IndexProvider.Monitor empty, UnknownType getConfig) : base(get, directoryFactory, defaultDirectoryStructure, empty, getConfig, context.databaseInfo().operationalMode) { this.outerInstance = outerInstance; }
public async Task RunMutationTest(MuTestOptions options) { try { if (!File.Exists(MuTestSettings.MSBuildPath)) { throw new MuTestInputException($"Unable to locate MSBuild Path at {MuTestSettings.MSBuildPath}. Please update MSBuildPath in MuTest.Console.exe.config if you are using different version"); } _stopwatch = new Stopwatch(); _stopwatch.Start(); _options = options; _chalk.Default("\nPreparing Required Files...\n"); DirectoryFactory.NumberOfMutantsExecutingInParallel = _options.ConcurrentTestRunners; _cppClass = new CppClass { Configuration = _options.Configuration, SourceClass = _options.SourceClass, Platform = _options.Platform, TestClass = _options.TestClass, TestProject = _options.TestProject, Target = _options.Target, SourceHeader = _options.SourceHeader, TestSolution = _options.TestSolution, IncludeBuildEvents = _options.IncludeBuildEvents }; Context = !_options.InIsolation ? DirectoryFactory.PrepareTestFiles(_cppClass) : DirectoryFactory.PrepareSolutionFiles(_cppClass); if (Context.TestContexts.Any()) { await ExecuteBuild(); await ExecuteTests(); if (!_options.DisableBuildOptimization) { Context.EnableBuildOptimization = true; } _chalk.Default("\nRunning Mutation Analysis...\n"); var defaultMutants = CppMutantOrchestrator.GetDefaultMutants(_options.SourceClass, _options.SpecificLines).ToList(); defaultMutants = _aridNodeMutantFilterer.FilterMutants(defaultMutants).ToList(); defaultMutants = _mutantsSelector.SelectMutants(_options.MutantsPerLine, defaultMutants).ToList(); _cppClass.Mutants.AddRange(defaultMutants); if (_cppClass.CoveredLineNumbers.Any()) { foreach (var mutant in _cppClass.Mutants) { if (_cppClass.CoveredLineNumbers.All(x => x != mutant.Mutation.LineNumber)) { mutant.ResultStatus = MutantStatus.NotCovered; } else if (mutant.Mutation.EndLineNumber > mutant.Mutation.LineNumber) { if (!_cppClass.CoveredLineNumbers.Any(x => x > mutant.Mutation.LineNumber && x <= mutant.Mutation.EndLineNumber)) { mutant.ResultStatus = MutantStatus.Skipped; } } } } _chalk.Default($"\nNumber of Mutants: {_cppClass.Mutants.Count}\n"); var sourceHash = _cppClass .SourceClass .GetCodeFileContent() .ComputeHash(); var testHash = _cppClass .TestClass .GetCodeFileContent() .ComputeHash(); _cppClass.Sha256 = (sourceHash + testHash).ComputeHash(); var data = await _client.GetFileDataFromStorage(_cppClass.Sha256); _cppClass.StoreInDb = true; if (data != null) { var cppClass = JsonConvert.DeserializeObject <CppClass>(data); cppClass.StoreInDb = false; cppClass.SourceClass = _cppClass.SourceClass; cppClass.SourceHeader = _cppClass.SourceHeader; cppClass.TestClass = _cppClass.TestClass; cppClass.TestProject = _cppClass.TestProject; cppClass.Configuration = _cppClass.Configuration; cppClass.Target = _cppClass.Target; cppClass.Platform = _cppClass.Platform; cppClass.TestSolution = _cppClass.TestSolution; cppClass.IncludeBuildEvents = _cppClass.IncludeBuildEvents; _cppClass = cppClass; } MutantsExecutor = new CppMutantExecutor(_cppClass, Context, MuTestSettings) { EnableDiagnostics = _options.EnableDiagnostics, KilledThreshold = _options.KilledThreshold, SurvivedThreshold = _options.SurvivedThreshold, NumberOfMutantsExecutingInParallel = _options.ConcurrentTestRunners }; _totalMutants = _cppClass.NotRunMutants.Count; _mutantProgress = 0; if (_cppClass.Mutants.Any() && data == null) { MutantsExecutor.MutantExecuted += MutantAnalyzerOnMutantExecuted; await MutantsExecutor.ExecuteMutants(); } await GenerateReports(); } } finally { if (Context != null) { DirectoryFactory.DeleteTestFiles(Context); } } }