コード例 #1
0
ファイル: Main.cs プロジェクト: vaginessa/MediaTester
 private void MediaTesterFullTest()
 {
     try
     {
         bool result = _mediaTester.FullTest();
     }
     finally
     {
         FinishMediaTesterRun();
     }
 }
コード例 #2
0
        static void Main(string[] args)
        {
            string testDirectory = null;

            if (args == null || args.Length < 1)
            {
                while (string.IsNullOrEmpty(testDirectory))
                {
                    Console.WriteLine();
                    Console.WriteLine();
                    Console.Write("Please enter a drive letter or path to test: ");
                    testDirectory = Console.ReadLine();
                }
                if (!testDirectory.Contains(@":\"))
                {
                    testDirectory = Path.Combine(testDirectory.Substring(0, 1).ToUpper() + @":\", MediaTester.TempSubDirectoryName);
                }
            }
            else
            {
                testDirectory = args[0];
            }

            testDirectory = testDirectory.TrimEnd('\\');
            if (!testDirectory.EndsWith(MediaTester.TempSubDirectoryName))
            {
                testDirectory = Path.Combine(testDirectory, MediaTester.TempSubDirectoryName);
            }

            Console.WriteLine();
            Console.WriteLine($"Bytes per file: {MediaTester.FILE_SIZE.ToString("#,##0")}");
            Console.WriteLine($"Data block size: {MediaTester.DATA_BLOCK_SIZE.ToString("#,##0")}");
            Console.WriteLine($"Blocks per file: {MediaTester.DATA_BLOCKS_PER_FILE.ToString("#,##0")}");
            Console.WriteLine($"Writing temp files to: {testDirectory}...");
            Console.WriteLine();

            var mediaTester = new MediaTester(testDirectory)
            {
            };

            mediaTester.AfterWriteBlock  += AfterWriteBlock;
            mediaTester.AfterQuickTest   += AfterQuickTest;
            mediaTester.AfterVerifyBlock += AfterVerifyBlock;
            mediaTester.OnException      += OnMediaTesterException;

            bool result = mediaTester.FullTest();

            Console.WriteLine();
            Console.WriteLine("Media Test Summary...");
            Console.WriteLine("------------------------------------------------");
            Console.WriteLine("Result: " + (result ? "PASS" : "FAIL"));
            Console.WriteLine($"Temp File Path: {mediaTester.Options.TestDirectory}");
            Console.WriteLine($"Total bytes attempted: {mediaTester.Options.TotalBytesToTest.ToString("#,##0")}");

            if (!mediaTester.Options.StopProcessingOnFailure || mediaTester.TotalBytesVerified > 0)
            {
                Console.WriteLine($"Verified bytes: {mediaTester.TotalBytesVerified.ToString("#,##0")}");
            }

            if (!mediaTester.Options.StopProcessingOnFailure || mediaTester.TotalBytesFailed > 0)
            {
                Console.WriteLine($"Failed bytes: {mediaTester.TotalBytesFailed.ToString("#,##0")}");
            }

            if (mediaTester.FirstFailingByteIndex > 0)
            {
                Console.WriteLine($"First failing byte index: {mediaTester.FirstFailingByteIndex.ToString("#,##0")}{(mediaTester.Options.QuickFirstFailingByteMethod ? " (quick method)" : string.Empty)}");
            }

            if (!result)
            {
                Console.WriteLine();
                for (int i = 0; i < 20; i++)
                {
                    Console.Write(i % 2 == 0 ? string.Empty : "   ");
                    for (int j = 0; j < 15; j++)
                    {
                        Console.Write("FAIL!  ");
                    }
                    Console.WriteLine();
                }
            }

            Console.WriteLine();
            Console.WriteLine("Press enter to continue...");
            Console.ReadLine();
        }