Esempio n. 1
0
        public async Task AnalizeZeroFileSizeTest()
        {
            var folderCheckSum = new FolderCheckSum(existFolderPath);
            var progress       = new Progress <FileResult>();

            await folderCheckSum.AnalizeAsync(progress);

            Assert.IsTrue(
                folderCheckSum.FolderResult.FilesCollection.Any(r => r.Status.Equals(FileAnalyzeStatus.ZeroFile)),
                "Файл с нулевым размером не определен");
        }
Esempio n. 2
0
        public async Task AnalizeErrorsTest()
        {
            var folderCheckSum = new FolderCheckSum(existFolderPath);
            var progress       = new Progress <FileResult>();

            await folderCheckSum.AnalizeAsync(progress);

            Assert.IsTrue(
                folderCheckSum.FolderResult.FilesCollection.All(r => r.Status != FileAnalyzeStatus.Error),
                "Не все файлы прверены успешно");
        }
Esempio n. 3
0
        public void ProgressTest()
        {
            var folderCheckSum = new FolderCheckSum(existFolderPath);
            var progress       = new Progress <FileResult>();

            var progressCollection = new List <FileResult>();

            progress.ProgressChanged += delegate(object sender, FileResult e) { progressCollection.Add(e); };

            folderCheckSum.AnalizeAsync(progress).Wait();

            Assert.AreEqual(folderCheckSum.FolderResult.FilesCollection.Count, progressCollection.Count,
                            "Количество отловленных событий изменения прогресса не соответствует числу проверенных файлов");
        }
Esempio n. 4
0
        public async Task AnalizeSmokeTest()
        {
            var isDone         = false;
            var xmlFileName    = string.Empty;
            var progress       = new Progress <FileResult>();
            var folderCheckSum = new FolderCheckSum(existFolderPath);

            folderCheckSum.Analized += delegate(object sender, string e)
            {
                isDone      = true;
                xmlFileName = e;
            };

            await folderCheckSum.AnalizeAsync(progress);

            Assert.IsTrue(isDone, "Анализ не закончился успешно");
            Assert.IsTrue(folderCheckSum.FolderResult.FilesCollection.Any(), "Результаты проверки пусты");
            Assert.IsTrue(new FileInfo(xmlFileName).Exists);
        }
Esempio n. 5
0
        private static void Main(string[] args)
        {
            var folderPath = GetfolderPath(args);

            try
            {
                var checkSumFolder = new FolderCheckSum(folderPath);

                //end of analysis event
                checkSumFolder.Analized += CheckSumFolder_Analized;

                //progress of analysis event
                var progress = new Progress <FileResult>();
                progress.ProgressChanged += Progress_ProgressChanged;

                checkSumFolder.AnalizeAsync(progress).Wait();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Esempio n. 6
0
        public async Task FileSizeTest()
        {
            var        zeroSizeFilePath    = new FileInfo($"{existFolderPath}{Path.DirectorySeparatorChar}{zeroSizeFileName}").FullName;
            var        size200FileSizePath = new FileInfo($"{existFolderPath}{Path.DirectorySeparatorChar}{size200FileName}").FullName;
            const long filesize200         = 200L;

            var folderCheckSum = new FolderCheckSum(existFolderPath);
            var progress       = new Progress <FileResult>();

            await folderCheckSum.AnalizeAsync(progress);

            var fileResults = folderCheckSum.FolderResult.FilesCollection;

            var zeroSiseResult = fileResults.FirstOrDefault(r => r.FileName.Equals(zeroSizeFilePath));

            Assert.IsNotNull(zeroSiseResult, "Файл с нулевой суммой не найден в результатах");
            Assert.AreEqual(FileAnalyzeStatus.ZeroFile, zeroSiseResult.Status, "Сумма байт файла с нулевым размером не равна нулю");

            var size200Result = fileResults.FirstOrDefault(r => r.FileName.Equals(size200FileSizePath)) as FileResultSuccess;

            Assert.IsNotNull(size200Result, "");
            Assert.AreEqual(filesize200, size200Result.CheckSum, $"Суммма байт файла не равна {filesize200}");
        }
Esempio n. 7
0
 public async Task OpenNotExistFolderTest()
 {
     var folderCheckSum = new FolderCheckSum(notExistFolderPath);
     var progress       = new Progress <FileResult>();
     await folderCheckSum.AnalizeAsync(progress);
 }