Exemplo n.º 1
0
        private static List <IReport> getReportGenerators(Options options, ISystemIO systemIO)
        {
            var reportGenerators = new List <IReport>();

            foreach (var format in options.OutputFormat)
            {
                string outputFilename = "GitCommitsAnalysisReport";
                if (!string.IsNullOrEmpty(options.ReportFilename))
                {
                    outputFilename = systemIO.GetPathWitoutExtension(options.ReportFilename);
                }
                var filename = $"{options.OutputFolder}\\{outputFilename}";
                if (format == OutputFormat.Text)
                {
                    reportGenerators.Add(new TextFileReport(systemIO, filename, options));
                }
                if (format == OutputFormat.Markdown)
                {
                    reportGenerators.Add(new MarkdownReport(systemIO, filename, options));
                }
                if (format == OutputFormat.Json)
                {
                    reportGenerators.Add(new JsonReport(systemIO, filename, options));
                }
                if (format == OutputFormat.HTML)
                {
                    reportGenerators.Add(new HTMLReport(systemIO, filename, options));
                }
                if (format == OutputFormat.Excel)
                {
                    reportGenerators.Add(new ExcelReport(systemIO, filename, options));
                }
            }
            return(reportGenerators);
        }
Exemplo n.º 2
0
 protected BaseReport(ISystemIO systemIO, string reportFilename, Options options)
 {
     this.SystemIO            = systemIO;
     this.ReportFilename      = reportFilename;
     this.Title               = options.Title;
     this.NumberOfFilesToList = options.NumberOfFilesInList;
 }
Exemplo n.º 3
0
        public Analyzer(IFileInfoIO fileInfoIO, ISystemIO systemio)
        {
            var loggerFactory = new LoggerFactory().AddConsole().AddDebug();

            logger      = loggerFactory.CreateLogger <Analyzer>();
            _fileInfoIO = fileInfoIO;
            _systemio   = systemio;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Extension method for ISystemIO which determines whether the given path is a symlink.
 /// </summary>
 /// <param name="systemIO">ISystemIO implementation</param>
 /// <param name="path">File or folder path</param>
 /// <param name="attributes">File attributes</param>
 /// <returns>Whether the path is a symlink</returns>
 public static bool IsSymlink(this ISystemIO systemIO, string path, FileAttributes attributes)
 {
     // Not all reparse points are symlinks.
     // For example, on Windows 10 Fall Creator's Update, the OneDrive folder (and all subfolders)
     // are reparse points, which allows the folder to hook into the OneDrive service and download things on-demand.
     // If we can't find a symlink target for the current path, we won't treat it as a symlink.
     return((attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint && !string.IsNullOrEmpty(systemIO.GetSymlinkTarget(path)));
 }
Exemplo n.º 5
0
        public void DirectoryDelete_DeletesExistingDirectory(string testPath, ISystemIO io)
        {
            Directory.CreateDirectory(testPath);
            io.Directory.Delete(testPath);
            var exists = Directory.Exists(testPath);

            IsFalse(exists);
        }
        public void Setup()
        {
            _ioSubstitute = Substitute.For <ISystemIO>();
            _solutionFileParserSubstitute = Substitute.For <ISolutionFileParser>();
            _solutionFactorySubstitute    = Substitute.For <ISolutionFactory>();

            _reader = new SolutionReader(_ioSubstitute, _solutionFactorySubstitute, _solutionFileParserSubstitute);
        }
Exemplo n.º 7
0
        public void SetUp()
        {
            _projectInSolutionSubstitute = Substitute.For <IProjectInSolution>();
            _ioSubstitute = Substitute.For <ISystemIO>();
            _runSettingsFileReaderSubstitute = Substitute.For <IRunSettingsFileReader>();

            _projectInSolutionSubstitute.AbsolutePath.Returns(DefaultProjectFilePath);
        }
Exemplo n.º 8
0
        public void CreateDirectory_CreatesDirectory(string testPath, ISystemIO io)
        {
            io.Directory.CreateDirectory(testPath);
            var exists = Directory.Exists(testPath);

            Directory.Delete(testPath);

            IsTrue(exists);
        }
Exemplo n.º 9
0
        public HvacManager(ISystemClock clock, ISystemIO systemIO, IEnumerable <IHvacAlgorithm> validModes)
        {
            _Clock = clock;
            _IO    = systemIO;

            ValidModes            = validModes.ToList();
            _CurrentHvacAlgorithm = ValidModes.First(x => x.GetType() == typeof(NoHeatCool));

            _Clock.TimeTick += Clock_TimeTick;
        }
Exemplo n.º 10
0
        public MainViewModel(IChangeViewCommandProvider changeViewCommandProvider, IHvacManager hvacManager, ISystemIO systemIO)
        {
            // Dependency injection for these commands, makes this class simpler and more self contained.
            OpenHistoryCommand  = changeViewCommandProvider.ShowHistoryViewCommand;
            OpenSettingsCommand = changeViewCommandProvider.ShowSettingsViewCommand;

            _SystemIO = systemIO;
            _SystemIO.CurrentSensorValues.PropertyChanged += CurrentSensorValues_PropertyChanged;

            _HvacManager = hvacManager;
            _HvacManager.PropertyChanged += HvacManager_PropertyChanged;
            _HvacManager.CurrentSetPoint.PropertyChanged += CurrentSetPoint_PropertyChanged;
        }
Exemplo n.º 11
0
        internal Project(IProjectInSolution projectInSolution, ISystemIO io, IRunSettingsFileReader runSettingsFileReader)
        {
            if (projectInSolution == null)
            {
                throw new ArgumentNullException(nameof(projectInSolution));
            }

            _io = io ?? throw new ArgumentNullException(nameof(io));
            _runSettingsFileReader =
                runSettingsFileReader ?? throw new ArgumentNullException(nameof(runSettingsFileReader));

            _projectFileInfo = new FileInfo(projectInSolution.AbsolutePath);

            var content = _io.File.ReadAllText(projectInSolution.AbsolutePath);

            using (var stream = new MemoryStream(Encoding.UTF8.GetBytes(content ?? "")))
                using (var reader = XmlReader.Create(stream))
                {
                    _evaluatedProject = new Microsoft.Build.Evaluation.Project(reader);
                }
        }
Exemplo n.º 12
0
 static SystemIO()
 {
     IO_WIN = new SystemIOWindows();
     IO_SYS = new SystemIOLinux();
     IO_OS  = Platform.IsClientWindows ? IO_WIN : IO_SYS;
 }
Exemplo n.º 13
0
 public JsonReport(ISystemIO systemIO, string reportFilename, Options options)
 {
     this.reportFilename = reportFilename;
     this.title          = options.Title;
     this.systemIO       = systemIO;
 }
Exemplo n.º 14
0
 public TextFileReport(ISystemIO systemIO, string reportFilename, Options options) : base(systemIO, reportFilename, options)
 {
 }
Exemplo n.º 15
0
        public void SimpleEnumerateDirectories_ReturnsCorrectEnumeration(string testPath, ISystemIO io)
        {
            Directory.CreateDirectory(testPath);
            Directory.CreateDirectory($"{testPath}/a");
            Directory.CreateDirectory($"{testPath}/b");
            Directory.CreateDirectory($"{testPath}/c");

            var contents = io.Directory.EnumerateDirectories(testPath).ToList();

            io.Directory.Delete(testPath, true);

            Multiple(() =>
            {
                AreEqual(3, contents.Count);
                IsTrue(contents.Any(item => item.EndsWith("a")));
                IsTrue(contents.Any(item => item.EndsWith("b")));
                IsTrue(contents.Any(item => item.EndsWith("c")));
            });
        }
Exemplo n.º 16
0
 public ExcelReport(ISystemIO systemIO, string reportFilename, Options options) : base(systemIO, reportFilename, options)
 {
     this.systemIO = systemIO;
 }
 public GitCommitsAnalysis(ISystemIO fileHandling, IEnumerable <IReport> reports, Options options)
 {
     this.fileHandling = fileHandling;
     this.reports      = reports;
     this.options      = options;
 }
Exemplo n.º 18
0
        public void RecursiveDirectoryDelete_DeletesNonEmptyDirectory(string testPath, ISystemIO io)
        {
            Directory.CreateDirectory(testPath);
            Directory.CreateDirectory($"{testPath}/a");
            io.Directory.Delete(testPath, true);

            IsFalse(Directory.Exists(testPath));
        }
 public RunSettingsFileReader(ISystemIO io) : base(io, RunSettingsFileGlob)
 {
 }
Exemplo n.º 20
0
        public void NonRecursiveDirectoryDelete_DeletesEmptyDirectory(string testPath, ISystemIO io)
        {
            Directory.CreateDirectory(testPath);
            io.Directory.Delete(testPath, false);

            IsFalse(Directory.Exists(testPath));
        }
Exemplo n.º 21
0
        public void FilteredEnumerateDirectories_ReturnsCorrectEnumeration(string testPath, ISystemIO io)
        {
            Directory.CreateDirectory(testPath);
            Directory.CreateDirectory($"{testPath}/a.exe");
            Directory.CreateDirectory($"{testPath}/b.txt");
            Directory.CreateDirectory($"{testPath}/c.exe");

            var contents = io.Directory.EnumerateDirectories(testPath, "*.exe").ToList();

            io.Directory.Delete(testPath, true);

            Multiple(() =>
            {
                AreEqual(2, contents.Count);
                IsTrue(contents.Any(item => item.EndsWith("a.exe")));
                IsTrue(contents.Any(item => item.EndsWith("c.exe")));
            });
        }
Exemplo n.º 22
0
 public MarkdownReport(ISystemIO systemIO, string reportFilename, Options options) : base(systemIO, reportFilename, options)
 {
 }
Exemplo n.º 23
0
 /// <summary>
 /// Extension method for ISystemIO which determines whether the given path is a symlink.
 /// </summary>
 /// <param name="systemIO">ISystemIO implementation</param>
 /// <param name="path">File or folder path</param>
 /// <returns>Whether the path is a symlink</returns>
 public static bool IsSymlink(this ISystemIO systemIO, string path)
 {
     return(systemIO.IsSymlink(path, systemIO.GetFileAttributes(path)));
 }
 public SystemIOLoggingDecorator(ISystemIO baseIO)
 {
     //TODO: finish implementing
     _BaseIO = baseIO;
     throw new NotImplementedException();
 }
Exemplo n.º 25
0
 public SolutionReader(ISystemIO io, ISolutionFactory solutionFactory, ISolutionFileParser solutionFileParser) : base(io, SlnFileGlob)
 {
     _solutionFactory    = solutionFactory ?? throw new ArgumentNullException(nameof(solutionFactory));
     _solutionFileParser = solutionFileParser ?? throw new ArgumentNullException(nameof(solutionFileParser));
 }
Exemplo n.º 26
0
        public void Setup()
        {
            _ioSubstitute = Substitute.For <ISystemIO>();

            _fileReader = new RunSettingsFileReader(_ioSubstitute);
        }
Exemplo n.º 27
0
        public void NonRecursiveDirectoryDelete_FailsToDeleteNonEmptyDirectory(string testPath, ISystemIO io)
        {
            var deletionSucceeded = true;

            Directory.CreateDirectory(testPath);
            Directory.CreateDirectory($"{testPath}/a");

            try
            {
                io.Directory.Delete(testPath, false);
            }
            catch (IOException)
            {
                deletionSucceeded = false;
            }

            var exists = Directory.Exists(testPath);

            Directory.Delete(testPath, true);

            Multiple(() =>
            {
                IsTrue(exists);
                IsFalse(deletionSucceeded);
            });
        }
Exemplo n.º 28
0
        // Initialize it in the ctor

        public FileHandling(ISystemIO systemIo = null)
        {
            Directory = systemIo?.Directory ?? new Directory();
            File      = systemIo?.File ?? new File();
        }
Exemplo n.º 29
0
 protected FileReader(ISystemIO io, string fileNameGlob)
 {
     _fileGlob = Glob.Parse(fileNameGlob);
     _io       = io ?? throw new ArgumentNullException(nameof(io));
 }