static void Main(string[] args) { ExportFamily exportFamily = ExportFamily.Microsoft; bool showHelp = false; var p = new OptionSet { "Usage: GoogleDriveOfflineBackup.CLI.exe [OPTIONS]", "Backup the contents of your Google Drive locally.", { "h|help", "show this help message and exit", v => showHelp = v != null }, { "e=|export=", "Select the formats to export to (Microsoft, Open, Pdf)", v => exportFamily = ParseExportFamily(v) } }; List<string> extra; try { extra = p.Parse(args); } catch (OptionException e) { Console.WriteLine(e.Message); Console.WriteLine("Try with --help for more information"); return; } if (showHelp || extra.Any()) { p.WriteOptionDescriptions(Console.Out); return; } // TODO: be able to backup only a subfolder (use PathResolver for that) e.g. --root=/Photos/Summer var driveServiceFactory = new DriveServiceFactory(); var driveService = driveServiceFactory.Create(); var fileSystem = new FileSystem(); var downloader = new Downloader(driveService, fileSystem); var walker = new Walker(driveService); var backupService = new FileBackupService(walker, downloader, fileSystem); Console.WriteLine("Export formats: {0}", exportFamily); downloader.ExportFamily = exportFamily; downloader.Downloading += (object sender, FileDownloadingEventArgs e) => { Console.WriteLine( "Downloading {0} (size {1}) in {2}", e.File.Name, e.File.Size, e.LocalPath); }; backupService.Backup("."); Console.Write("Press enter to exit"); Console.ReadLine(); }
public void Constructors() { var log = LogManager.GetLogger(typeof(TaskContextTest)); var data = new Dictionary<string, object>(); var fileSystem = new FileSystem(); var context = new TaskContext(log); Assert.NotNull(context.Log); Assert.NotNull(context.FileSystem); Assert.NotNull(context.Data); Assert.AreEqual(log,context.Log); context = new TaskContext(log,data); Assert.NotNull(context.Log); Assert.NotNull(context.FileSystem); Assert.NotNull(context.Data); Assert.AreEqual(log,context.Log); Assert.AreEqual(data,context.Data); context = new TaskContext(log,fileSystem); Assert.NotNull(context.Log); Assert.NotNull(context.FileSystem); Assert.NotNull(context.Data); Assert.AreEqual(log,context.Log); Assert.AreEqual(fileSystem,context.FileSystem); context = new TaskContext(log,fileSystem,data); Assert.NotNull(context.Log); Assert.NotNull(context.FileSystem); Assert.NotNull(context.Data); Assert.AreEqual(log,context.Log); Assert.AreEqual(fileSystem,context.FileSystem); Assert.AreEqual(data,context.Data); }
public void StoreImagesFromDicomdir_CreatesImageStoreDirectory() { // Arrange var fileSystem = Substitute.For<IFileSystem>(); var defaultFileSystem = new FileSystem(); fileSystem.Path.Returns(defaultFileSystem.Path); var directoryInfoBase = Substitute.For<DirectoryInfoBase>(); directoryInfoBase.Exists.Returns(false); var directoryInfoFactory = Substitute.For<IDirectoryInfoFactory>(); directoryInfoFactory.FromDirectoryName(Arg.Any<string>()).Returns(directoryInfoBase); fileSystem.DirectoryInfo.Returns(directoryInfoFactory); var directoryBase = Substitute.For<DirectoryBase>(); directoryBase.GetCurrentDirectory().Returns(string.Empty); fileSystem.Directory.Returns(directoryBase); var dicomImageComposer = Substitute.For<IDicomImageComposer>(); var dicomdirImageStorageProvider = new DicomdirImageStorageProvider(fileSystem, dicomImageComposer); var dicomdirInfos = new DicomdirInfos { Images = Enumerable.Empty<ImageInfo>() }; // Act dicomdirImageStorageProvider.StoreImagesFromDicomdir(dicomdirInfos); // Assert Assert.That(() => directoryInfoFactory.Received(1).FromDirectoryName(DicomdirImageStorageProvider.IMAGE_STORE_LOCATION), Throws.Nothing); Assert.That(() => directoryInfoBase.Received(1).Exists, Throws.Nothing); Assert.That(() => directoryInfoBase.Received(1).Create(), Throws.Nothing); }
public void PresentTabs_ShouldPresentTheDefaultNumberOfItems() { //Arrange var tabKey = "diamond-rings"; var tabId = "engagement-rings"; var xmlSource = new XmlSourceFactory(); var tabsRepository = new TabsRepository(xmlSource); var jewelryRepository = new JewelRepository(new SettingManager()); var fileSystem = new FileSystem(); var pathBarGenerator = MockRepository.GenerateStub<IPathBarGenerator>(); var mapper = MockRepository.GenerateStub<IMappingEngine>(); TabsController controller = new TabsController(tabsRepository,jewelryRepository,fileSystem,xmlSource,pathBarGenerator, mapper); var viewModel = MockRepository.GenerateStub<TabsViewModel>(); viewModel.TabKey = tabKey; viewModel.TabId = tabId; //Act var resultview = controller.SearchTabs(viewModel); //Assert var model = resultview.Model as TabsViewModel; model.JewelryInTabContainersCollection.Count.ShouldBe(10); }
public SolutionIntegrity() { var fileSystem = new FileSystem(); var projectParser = new MsBuildProjectParser(new XmlDocumentLoader()); this.createCheckFunction = projectsInSolution => new SolutionIntegrityCheck(fileSystem, projectsInSolution, projectParser); this.solutionParser = new VsSolutionParser(fileSystem); }
static Paths() { if(FS == null) FS = new FileSystem(); BasePath = FS.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + "\\"; PluginPath = FS.Path.Combine(SimpleConfig.DataDirectory, "Plugins"); DatabasePath = FS.Path.Combine(SimpleConfig.DataDirectory, "Database"); DatabasePath = FS.Path.Combine(DatabasePath, "master.db3"); }
internal Paths(string dataDirectory) { // WARN - Do Not Call Config.Instance from in here!!! if (FS == null) FS = new FileSystem(); try { if (WorkingDirectory == null) { if (Assembly.GetEntryAssembly() != null) WorkingDirectory = Assembly.GetEntryAssembly().Location; else { WorkingDirectory = Assembly.GetExecutingAssembly().Location; } } } catch { } UserDirectory = System.IO.Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Octgn"); BasePath = FS.Path.GetDirectoryName(WorkingDirectory) + "\\"; LogsPath = FS.Path.Combine(BasePath, "Logs"); CurrentLogPath = FS.Path.Combine(LogsPath, "log.txt"); PreviousLogPath = FS.Path.Combine(LogsPath, "log.txt.1"); DataDirectory = dataDirectory; PluginPath = FS.Path.Combine(UserDirectory, "Plugins"); //DatabasePath = FS.Path.Combine(SimpleConfig.Get().DataDirectory, "Database"); DatabasePath = FS.Path.Combine(DataDirectory, "GameDatabase"); ImageDatabasePath = FS.Path.Combine(DataDirectory, "ImageDatabase"); ConfigDirectory = System.IO.Path.Combine(UserDirectory, "Config"); FeedListPath = FS.Path.Combine(ConfigDirectory, "feeds.txt"); LocalFeedPath = FS.Path.Combine(UserDirectory, "LocalFeed"); FS.Directory.CreateDirectory(LocalFeedPath); DeckPath = FS.Path.Combine(DataDirectory, "Decks"); MainOctgnFeed = "https://www.myget.org/F/octgngames/"; Task.Factory.StartNew(() => { foreach (var prop in this.GetType().GetProperties()) { Log.InfoFormat("Path {0} = {1}", prop.Name, prop.GetValue(this, null)); } }); }
private void SelectNodeVersion(DeploymentContext context) { var fileSystem = new FileSystem(); ILogger innerLogger = context.Logger.Log(Resources.Log_SelectNodeJsVersion); try { string sourcePath = String.IsNullOrEmpty(ProjectPath) ? RepositoryPath : ProjectPath; string log = NodeSiteEnabler.SelectNodeVersion(fileSystem, Environment.ScriptPath, sourcePath, context.Tracer); innerLogger.Log(log); } catch (Exception ex) { innerLogger.Log(ex); throw; } }
/// <summary> /// Initializes a new instance of the ViewModelLocator class. /// </summary> public ViewModelLocator() { ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default); ////if (ViewModelBase.IsInDesignModeStatic) ////{ //// // Create design time view services and models //// SimpleIoc.Default.Register<IDataService, DesignDataService>(); ////} ////else ////{ //// // Create run time view services and models //// SimpleIoc.Default.Register<IDataService, DataService>(); ////} var fileSystem = new FileSystem(); SimpleIoc.Default.Register<IFileSystem>(() => fileSystem); SimpleIoc.Default.Register<IMainModelSerializer>(() => new MainModelSerializer(DataDirectoryDeriver.DeriveDataDirectory(), fileSystem)); SimpleIoc.Default.Register<MainViewModel>(); }
public CommandArguments(string[] args) { _vfsurl = ConfigurationManager.AppSettings["vfsurl"]; _username = ConfigurationManager.AppSettings["username"]; _password = ConfigurationManager.AppSettings["password"]; foreach (string arg in args) { if (arg.StartsWith("/")) { _flags[arg] = arg; } else { if (!String.IsNullOrEmpty(_path)) { throw new ArgumentException("mulitple path arguments!"); } _path = arg; } } if (_path == null) { throw new ArgumentNullException("path", "Missing path argument."); } var localFileSystem = new FileSystem(); var remoteFileSystem = new VfsFileSystem(_vfsurl, _username, _password); if (!_path.Contains(":")) { _path = System.IO.Path.Combine(remoteFileSystem.Directory.GetCurrentDirectory(), _path); } var isVfs = _path.StartsWith("x:", StringComparison.OrdinalIgnoreCase); _fileSystem = isVfs ? (IFileSystem)remoteFileSystem : localFileSystem; }
public void PresentTabs_ShouldReturntheRightNumberOfItemsAfterMetalWhiteGoldFilter() { //Arrange var tabKey = "diamond-rings"; var tabId = "engagement-rings"; var xmlSource = new XmlSourceFactory(); var tabsRepository = new TabsRepository(xmlSource); var jewelryRepository = new JewelRepository(new SettingManager()); var fileSystem = new FileSystem(); var pathBarGenerator = MockRepository.GenerateStub<IPathBarGenerator>(); var mapper = MockRepository.GenerateStub<IMappingEngine>(); TabsController controller = new TabsController(tabsRepository, jewelryRepository, fileSystem, xmlSource,pathBarGenerator, mapper); var viewModel = new TabsViewModel(); viewModel.TabKey = tabKey; viewModel.TabId = tabId; viewModel.MetalFilter = JewelMediaType.WhiteGold; //Act var resultview = controller.SearchTabs(viewModel); //Assert var model = resultview.Model as TabsViewModel; model.JewelryInTabContainersCollection.Should().HaveCount(9).And.OnlyContain(x=> x.PictureURL.Contains("wg")); }
private static void DeleteAnyExistingReportsForThisJobIdentifier(string jobIdentifier) { IFileSystem fileSystem = new FileSystem(); IPathHelper pathHelper = new PathHelper(fileSystem, new TestReportConfiguration()); var reportsPathResponse = pathHelper.GetReportsPath(jobIdentifier); Assert.IsTrue(reportsPathResponse.IsSuccessful, "Cannot determine output path for reports"); var folder = reportsPathResponse.Result; foreach (var existingReportFile in fileSystem.Directory.EnumerateFiles(folder)) { Console.WriteLine("Deleting existing report file before running test: {0}", existingReportFile); fileSystem.File.Delete(existingReportFile); } }
public void StoreImagesFromDicomdir_ComposerIsCalled() { // Arrange var fileSystem = Substitute.For<IFileSystem>(); var dicomImageComposer = Substitute.For<IDicomImageComposer>(); var defaultFileSystem = new FileSystem(); fileSystem.Path.Returns(defaultFileSystem.Path); var dicomdirImageStorageProvider = new DicomdirImageStorageProvider(fileSystem, dicomImageComposer); var dicomdirInfos = new DicomdirInfos { Images = new List<ImageInfo> { new ImageInfo { SeriesInstanceUID = new InfoIdentifier("1.2"), ReferencedFileID = "1" }, new ImageInfo { SeriesInstanceUID = new InfoIdentifier("1.2"), ReferencedFileID = "2" }, new ImageInfo { SeriesInstanceUID = new InfoIdentifier("1.3"), ReferencedFileID = "1" }, new ImageInfo { SeriesInstanceUID = new InfoIdentifier("1.3"), ReferencedFileID = "2" } }, OriginalDicomdirFileLocation = string.Empty }; // Act dicomdirImageStorageProvider.StoreImagesFromDicomdir(dicomdirInfos); // Assert Assert.That(() => dicomImageComposer.Received(1).Compose(Arg.Any<IEnumerable<string>>(), "1.2.dcm"), Throws.Nothing); Assert.That(() => dicomImageComposer.Received(1).Compose(Arg.Any<IEnumerable<string>>(), "1.3.dcm"), Throws.Nothing); }
public PluginHandlerTest() { fileSystem = new System.IO.Abstractions.FileSystem(); pathWrapper = new PathWrapper(fileSystem); }
static void Main(string[] args) { string sourcePath = null; string targetPath = null; string filePattern = null; FileAttributes fileAttributes = FileAttributes.Normal; bool help = false; // Create the command line option set. OptionSet optionSet = new OptionSet(); optionSet.Add("?", "Displays this help message.", v => help = true); optionSet.Add("td:", "Target Directory.", v => targetPath = v); optionSet.Add("sd:", "Source Directory.", v => sourcePath = v); optionSet.Add("fp:", @"File Pattern. Optional. Defaults to ""*.*"".", v => filePattern = v ?? "*.*"); optionSet.Add("fa:", @"ile Attributes. Optional. Comma delimited list. Defaults to ""Any"".", v => fileAttributes = v == null ? FileAttributes.Normal : (FileAttributes)Enum.Parse(typeof(FileAttributes), v)); List<string> unknownOptions = optionSet.Parse(args); // using(ConsoleWriter consoleWriter = new ConsoleWriter()) { if (unknownOptions != null && unknownOptions.Any()) { unknownOptions.ForEach(o => consoleWriter.WriteWarning(string.Format("Option not known: \"{0}\".", o))); consoleWriter.WriteInformation(GetForHelpMessage()); return; } if (help) { consoleWriter.WriteInformation(GetHelpMessage(optionSet)); return; } if (targetPath == null) { consoleWriter.WriteError("Target Directory not specified."); consoleWriter.WriteInformation(GetForHelpMessage()); return; } if (sourcePath == null) { consoleWriter.WriteError("Source Directory not specified."); consoleWriter.WriteInformation(GetForHelpMessage()); return; } var fileSystem = new System.IO.Abstractions.FileSystem(); Cleaner.Clean(fileSystem, targetPath, sourcePath, filePattern, fileAttributes); } }
internal Paths() { Log.Info("Creating paths"); if (FS == null) FS = new FileSystem(); try { if (WorkingDirectory == null) WorkingDirectory = Assembly.GetEntryAssembly().Location; } catch { } BasePath = FS.Path.GetDirectoryName(WorkingDirectory) + "\\"; DataDirectory = SimpleConfig.Get().DataDirectory; PluginPath = FS.Path.Combine(DataDirectory, "Plugins"); //DatabasePath = FS.Path.Combine(SimpleConfig.Get().DataDirectory, "Database"); DatabasePath = FS.Path.Combine(DataDirectory, "GameDatabase"); ImageDatabasePath = FS.Path.Combine(DataDirectory, "ImageDatabase"); ConfigDirectory = System.IO.Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Octgn", "Config"); //ConfigDirectory = FS.Path.Combine(SimpleConfig.Get().DataDirectory, "Config"); FeedListPath = FS.Path.Combine(ConfigDirectory, "feeds.txt"); LocalFeedPath = FS.Path.Combine(DataDirectory, "LocalFeed"); FS.Directory.CreateDirectory(LocalFeedPath); DeckPath = FS.Path.Combine(DataDirectory, "Decks"); MainOctgnFeed = "https://www.myget.org/F/octgngames/"; foreach (var prop in this.GetType().GetProperties()) { Log.InfoFormat("Path {0} = {1}",prop.Name,prop.GetValue(this,null)); } }
/// <summary> /// Trigger task execution. /// </summary> /// <returns>True if the task succeeded.</returns> public override bool Execute() { // Load configuration FileSystem fileSystem = new FileSystem(); ConfigurationLoader configurationLoader = new ConfigurationLoader(fileSystem); IndexConfiguration indexConfiguration; try { indexConfiguration = configurationLoader.Load(fileSystem.Path.GetDirectoryName(this.ProjectPath), this.ConfigurationFile); } catch (ConfigurationException configurationException) { // Report generation errors this.ReportErrors(configurationException.GenerationErrors); return false; } catch (Exception exception) { this.Log.LogError(string.Empty, string.Empty, string.Empty, this.ConfigurationFile, 0, 0, 0, 0, string.Format("Error during loading configuration: {0}", exception.Message)); return false; } // Parse compilation symbols string[] compilationSymbols = new string[0]; if (!string.IsNullOrWhiteSpace(this.CompilationSymbols)) { compilationSymbols = this.CompilationSymbols .Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries) .Select(x => x.Trim()).ToArray(); } // Instantiate a ProjBook engine ProjbookEngine projbookEngine = new ProjbookEngine(fileSystem, this.ProjectPath, this.ExtensionPath, indexConfiguration, this.OutputDirectory, compilationSymbols.Contains(NOPDF_SYMBOL)); // Run generation bool success = true; GenerationError[] errors = projbookEngine.GenerateAll(); // Report generation errors this.ReportErrors(errors); // Stop processing in case of error if (errors.Length > 0) success = false; return success; }
internal UpdaterContext() { FileSystem = new FileSystem(); }
private void Push() { // Run the synchronisers. var fileSystem = new System.IO.Abstractions.FileSystem(); lock (_filePushTasks) { // clone list and then pass it to new thread for processing? foreach (KeyValuePair<string, string> kvp in _filePushTasks) { Pusher.PushFile(fileSystem, kvp.Key, kvp.Value); //_filePushTasks.Remove(kvp.Key); } _filePushTasks.Clear(); } // kick off new thread which runs through list? }
public RustProjectNode(CommonProjectPackage package) : base(package, Utilities.GetImageList(new System.Drawing.Bitmap(typeof(RustProjectNode).Assembly.GetManifestResourceStream("VisualRust.Project.Resources.IconList.bmp")))) { this.CanFileNodesHaveChilds = false; this.CanProjectDeleteItems = true; this.ListenForStartupFileUpdates = false; this.OnProjectPropertyChanged += ReloadOnOutputChange; this.fs = new FileSystem(); }
public GameRepository() { if (FS == null) FS = new FileSystem(); }