Пример #1
0
        public void RemoveTestShouldRemoveLogFile()
        {
            var          lfn         = new Mock <ILogFileNameProvider>();
            const string logFileName = "lfn";

            lfn.Setup(m => m.GetLogFileName()).Returns(logFileName);
            var lfr   = new LogFileItemRemover(lfn.Object);
            var file1 = new FileInfoCollector.FileInformations()
            {
                FilePath = "file1"
            };
            var file2 = new FileInfoCollector.FileInformations()
            {
                FilePath = "file2"
            };
            var logFile = new FileInfoCollector.FileInformations()
            {
                FilePath = logFileName
            };
            var input = new List <FileInfoCollector.FileInformations>()
            {
                file1, file2, logFile
            };

            var result = lfr.Remove(input);

            Assert.IsTrue(result.Count == 2);
            Assert.IsTrue(result.Contains(logFile) == false);
        }
Пример #2
0
        public OutputReport Run(string path)
        {
            OutputReport report;

            try
            {
                var logFileNameProvider           = new DefaultLogFileNameProvider();
                var logFileRemover                = new LogFileItemRemover(logFileNameProvider);
                var currentFileInfo               = new FileInfoCollector(_fsl).CollectFileInfos(path);
                var currentFileInfoWithoutLogFile = logFileRemover.Remove(currentFileInfo);
                try
                {
                    var fileInfoFromLog = new LogInfoGatherer(_fsl, logFileNameProvider).GetFileInfoLogFromPath(path);
                    var fileInfoFromLogWithouLogFile = logFileRemover.Remove(fileInfoFromLog);
                    var pairedFileInfos =
                        new InfoPairer(new PairCreator(new FilenamePicker()), new CompareFileInfoOnPath()).Pair(
                            currentFileInfoWithoutLogFile, fileInfoFromLogWithouLogFile);
                    var fileModificationsList =
                        new FileModificationsListCreator(new ModificationClassificator()).CalculateFileModifications(
                            pairedFileInfos);
                    var fileModificationsListWithoutUnmodified = new UnmodifiedRemover().AlterList(fileModificationsList);
                    report = new FileModificationsReport(fileModificationsListWithoutUnmodified,
                                                         new ModificationItemToStringConverterUsingToString(), new HtmlLineBreaker());
                }
                catch (LfgLogFileDoesntExistException)
                {
                    report = new NewDirectoryReport();
                }
                new LogFileWriter(_fsl, new LogFileLinesFileInfoConverter(new LogLinesToFileInfoConverter()),
                                  logFileNameProvider).WriteLog(currentFileInfoWithoutLogFile, path);
            }
            catch (Exception ex) when(ex is FilesystemLayerException)
            {
                report = new ErrorMessageReport(ex.Message);
            }
            return(report);
        }