Exemplo n.º 1
0
        public void FileTypeMessageUpdatesTest()
        {
            var fileTypes = new List <FileType>
            {
                new FileType {
                    Extension = "exe", Length = 4829999
                },
                new FileType {
                    Extension = "txt", Length = 48299
                },
                new FileType {
                    Extension = "json", Length = 2954173289
                }
            };
            var dds = new DirectoryDataSummary
            {
                DirectoryCount = 3,
                FileCount      = 100,
                Size           = 34829918287,
                FileTypes      = fileTypes
            };

            var form = new MainForm();

            form.Show();
            _model.LoadStatsListView(form.lvStats, form.lvFileTypes, dds);
            Assert.AreEqual("File Types:     3", _model.FileTypesMessage);
        }
Exemplo n.º 2
0
        public void SetUp()
        {
            var mapper      = new Mapper(new MapperConfiguration(a => a.AddProfile(new MappingProfile())));
            var logTestPath = "C:\\Temp\\DirScanTestArea";
            var logFile     =
                Path.Combine(
                    @"C:\Temp\DirScanTestLoggingArea", "DirScanLogs",
                    $@"DirectoryLog_{DateTime.Now.Year,4:0000}{DateTime.Now.Month,2:00}{DateTime.Now.Day,2:00}_{DateTime.Now.Hour,2:00}-{DateTime.Now.Minute,2:00}-{_fileCount++, 2:00}.log");
            var errorLogFile =
                Path.Combine(
                    @"C:\Temp\DirScanTestLoggingArea", "DirScanErrorLogs",
                    $@"DirectoryLog_{DateTime.Now.Year,4:0000}{DateTime.Now.Month,2:00}{DateTime.Now.Day,2:00}_{DateTime.Now.Hour,2:00}-{DateTime.Now.Minute,2:00}-{_fileCount, 2:00}.log");

            var logger      = FileLogger.Create(logFile);
            var errorLogger = ErrorLoggerFactory.Create(errorLogFile);

            _dm = new DirectoryManager(errorLogger, logger, mapper);
            _dm.Scan(logTestPath);
            _dds = _dm.DirectoryDataSummary;
        }
Exemplo n.º 3
0
        private void ScanPath(string path, bool logDirectories = false)
        {
            var dirSvc = new DirectoryService(_errorLogger, _logger, _mapper);
            var dd     = dirSvc.Scan(path, logDirectories);

            if (dd.CanBeProcessed)
            {
                if (dd.DirectoryCount > 0)
                {
                    foreach (var dir in dd.Directories)
                    {
                        ScanPath(dir.FullName, logDirectories);
                    }
                }

                DirectoryDataSummary.DirectoryCount += dd.DirectoryCount;
                DirectoryDataSummary.FileCount      += dd.FileCount;
                DirectoryDataSummary.Size           += dd.DirectoryFileSize;
                DirectoryDataSummary.MergeFileTypes(dd.FileTypes.ToList());
            }
        }
Exemplo n.º 4
0
        private void LoadStatsListView(MainForm form)
        {
            var fileTypes = new List <FileType>
            {
                new FileType()
                {
                    Extension = "exe", Length = 4829999
                },
                new FileType()
                {
                    Extension = "txt", Length = 48299
                }
            };
            var dds = new DirectoryDataSummary()
            {
                DirectoryCount = 3,
                FileCount      = 100,
                Size           = 34829918287,
                FileTypes      = fileTypes
            };

            form._model.LoadStatsListView(form.lvStats, form.lvFileTypes, dds);
        }