Beispiel #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);
        }
 protected BaseReport(ISystemIO systemIO, string reportFilename, Options options)
 {
     this.SystemIO            = systemIO;
     this.ReportFilename      = reportFilename;
     this.Title               = options.Title;
     this.NumberOfFilesToList = options.NumberOfFilesInList;
 }
Beispiel #3
0
        public Analyzer(IFileInfoIO fileInfoIO, ISystemIO systemio)
        {
            var loggerFactory = new LoggerFactory().AddConsole().AddDebug();

            logger      = loggerFactory.CreateLogger <Analyzer>();
            _fileInfoIO = fileInfoIO;
            _systemio   = systemio;
        }
Beispiel #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)));
 }
Beispiel #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);
        }
        public void SetUp()
        {
            _projectInSolutionSubstitute = Substitute.For <IProjectInSolution>();
            _ioSubstitute = Substitute.For <ISystemIO>();
            _runSettingsFileReaderSubstitute = Substitute.For <IRunSettingsFileReader>();

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

            Directory.Delete(testPath);

            IsTrue(exists);
        }
Beispiel #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;
        }
Beispiel #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;
        }
Beispiel #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);
                }
        }
Beispiel #12
0
 static SystemIO()
 {
     IO_WIN = new SystemIOWindows();
     IO_SYS = new SystemIOLinux();
     IO_OS  = Platform.IsClientWindows ? IO_WIN : IO_SYS;
 }
 public JsonReport(ISystemIO systemIO, string reportFilename, Options options)
 {
     this.reportFilename = reportFilename;
     this.title          = options.Title;
     this.systemIO       = systemIO;
 }
 public TextFileReport(ISystemIO systemIO, string reportFilename, Options options) : base(systemIO, reportFilename, options)
 {
 }
Beispiel #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")));
            });
        }
 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;
 }
Beispiel #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)
 {
 }
Beispiel #20
0
        public void NonRecursiveDirectoryDelete_DeletesEmptyDirectory(string testPath, ISystemIO io)
        {
            Directory.CreateDirectory(testPath);
            io.Directory.Delete(testPath, false);

            IsFalse(Directory.Exists(testPath));
        }
Beispiel #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")));
            });
        }
Beispiel #22
0
 public MarkdownReport(ISystemIO systemIO, string reportFilename, Options options) : base(systemIO, reportFilename, options)
 {
 }
Beispiel #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();
 }
 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));
 }
Beispiel #26
0
        public void Setup()
        {
            _ioSubstitute = Substitute.For <ISystemIO>();

            _fileReader = new RunSettingsFileReader(_ioSubstitute);
        }
Beispiel #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);
            });
        }
Beispiel #28
0
        // Initialize it in the ctor

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