Skip to content

Commit

Permalink
Reorganize and rename projects.
Browse files Browse the repository at this point in the history
  • Loading branch information
Doug Krahmer committed Sep 22, 2018
1 parent 56c4b5a commit 7e134b8
Show file tree
Hide file tree
Showing 20 changed files with 263 additions and 274 deletions.
4 changes: 2 additions & 2 deletions MediaTester.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2010
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaTesterCli", "MediaTester\MediaTesterCli.csproj", "{82DBB478-8EF7-45B1-8200-F28BEF178019}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaTesterCli", "MediaTesterCli\MediaTesterCli.csproj", "{82DBB478-8EF7-45B1-8200-F28BEF178019}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaTesterLib", "MediaTesterLib\MediaTesterLib.csproj", "{D684ACBC-9D01-4515-8CB1-969C15B22C4D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaTesterGui", "MediaTesterGui\MediaTesterGui.csproj", "{CBC3129F-F13E-4BAD-BEFE-00EBF57D2C09}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MediaTester", "MediaTester\MediaTester.csproj", "{CBC3129F-F13E-4BAD-BEFE-00EBF57D2C09}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{65E9EA9D-88EF-42A3-8771-64D5465655E0}"
ProjectSection(SolutionItems) = preProject
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions MediaTesterGui/Main.cs → MediaTester/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MediaTesterGui
namespace MediaTester
{
public partial class Main : Form
{
MediaTesterLib.Options _mediaTesterOptions = Options.Deserialize();
MediaTester _mediaTester;
MediaTesterLib.MediaTester _mediaTester;
private Thread _mediaTesterThread;
const string PALCEHOLDER_VALUE = "---";
const string BYTES = " Bytes";
Expand Down Expand Up @@ -96,7 +96,7 @@ private void UpdateTargetInformation()
if (Directory.Exists(targetDirectory))
{
long lTargetTotalBytes;
long lTargetAvailableBytes = MediaTester.GetAvailableBytes(targetDirectory, out lTargetTotalBytes, actual: true);
long lTargetAvailableBytes = MediaTesterLib.MediaTester.GetAvailableBytes(targetDirectory, out lTargetTotalBytes, actual: true);
targetTotalBytes = $"{lTargetTotalBytes.ToString("#,##0")}{BYTES}";
targetAvailableBytes = $"{lTargetAvailableBytes.ToString("#,##0")}{BYTES}";
}
Expand Down Expand Up @@ -222,7 +222,7 @@ private void LogTestCompletion(bool success)
private void InitializeMediaTester()
{
UpdateOptionsFromUi();
_mediaTester = new MediaTester(_mediaTesterOptions);
_mediaTester = new MediaTesterLib.MediaTester(_mediaTesterOptions);
_mediaTester.OnException += OnMediaTesterException;
_mediaTester.AfterQuickTest += AfterQuickTest;
_mediaTester.AfterVerifyBlock += AfterVerifyBlock;
Expand All @@ -241,7 +241,7 @@ private void FinishMediaTesterRun()
EnableControls();
}

private void AfterWriteBlock(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long writeBytesPerSecond, int bytesWritten, int bytesFailedWrite)
private void AfterWriteBlock(MediaTesterLib.MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long writeBytesPerSecond, int bytesWritten, int bytesFailedWrite)
{
UpdateStatus(writeBytesPerSecond: writeBytesPerSecond,
writeBytesRemaining: mediaTester.Options.MaxBytesToTest - mediaTester.TotalBytesWritten,
Expand All @@ -257,12 +257,12 @@ private void AfterWriteBlock(MediaTester mediaTester, long absoluteDataBlockInde
}
}

private void AfterVerifyBlock(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long readBytesPerSecond, int bytesVerified, int bytesFailed)
private void AfterVerifyBlock(MediaTesterLib.MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long readBytesPerSecond, int bytesVerified, int bytesFailed)
{
AfterVerifyBlock(mediaTester, absoluteDataBlockIndex, absoluteDataByteIndex, testFilePath, readBytesPerSecond, bytesVerified, bytesFailed, false);
}

private void AfterVerifyBlock(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long readBytesPerSecond, int bytesVerified, int bytesFailed, bool isQuickTest = false)
private void AfterVerifyBlock(MediaTesterLib.MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long readBytesPerSecond, int bytesVerified, int bytesFailed, bool isQuickTest = false)
{
if (!isQuickTest)
UpdateStatus(readBytesPerSecond: readBytesPerSecond,
Expand All @@ -280,12 +280,12 @@ private void AfterVerifyBlock(MediaTester mediaTester, long absoluteDataBlockInd
}
}

private void AfterQuickTest(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long readBytesPerSecond, int bytesVerified, int bytesFailed)
private void AfterQuickTest(MediaTesterLib.MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long readBytesPerSecond, int bytesVerified, int bytesFailed)
{
AfterVerifyBlock(mediaTester, absoluteDataBlockIndex, absoluteDataByteIndex, testFilePath, readBytesPerSecond, bytesVerified, bytesFailed, true);
}

private void OnMediaTesterException(MediaTester mediaTester, Exception exception)
private void OnMediaTesterException(MediaTesterLib.MediaTester mediaTester, Exception exception)
{
WriteLog(mediaTester, $"{exception.Message}");
if (exception.InnerException != null)
Expand All @@ -294,8 +294,8 @@ private void OnMediaTesterException(MediaTester mediaTester, Exception exception
}
}

private delegate void WriteLogDelegate(MediaTester mediaTester, string message);
private void WriteLog(MediaTester mediaTester, string message)
private delegate void WriteLogDelegate(MediaTesterLib.MediaTester mediaTester, string message);
private void WriteLog(MediaTesterLib.MediaTester mediaTester, string message)
{
if (ActivityLogTextBox.InvokeRequired)
{
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<ProjectGuid>{CBC3129F-F13E-4BAD-BEFE-00EBF57D2C09}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>MediaTesterGui</RootNamespace>
<AssemblyName>MediaTesterGui</AssemblyName>
<RootNamespace>MediaTester</RootNamespace>
<AssemblyName>MediaTester</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<NuGetPackageImportStamp>
Expand Down Expand Up @@ -69,6 +69,7 @@
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
Expand Down
144 changes: 12 additions & 132 deletions MediaTester/Program.cs
Original file line number Diff line number Diff line change
@@ -1,139 +1,19 @@
using MediaTesterLib;
using System;
using System.IO;
using System;
using System.Windows.Forms;

namespace MediaTesterCli
namespace MediaTester
{
class Program
static class Program
{
static void Main(string[] args)
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
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.MaxBytesToTest.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();
}

private static void AfterWriteBlock(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long writeBytesPerSecond, int bytesWritten, int bytesFailedWrite)
{
if (bytesFailedWrite == 0)
{
WriteLog(mediaTester, $"Successfully wrote block {absoluteDataBlockIndex.ToString("#,##0")}. Byte index: {absoluteDataByteIndex.ToString("#,##0")} / {mediaTester.Options.MaxBytesToTest.ToString("#,##0")}. {writeBytesPerSecond.ToString("#,##0")} B/sec ({mediaTester.ProgressPercent.ToString("0.00")}%)");
}
else
{
WriteLog(mediaTester, $"FAILED writing block {absoluteDataBlockIndex.ToString("#,##0")}. Byte index: {absoluteDataByteIndex.ToString("#,##0")} / {mediaTester.Options.MaxBytesToTest.ToString("#,##0")}. ({mediaTester.ProgressPercent.ToString("0.00")}%)");
}
}

private static void AfterVerifyBlock(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePath, long readBytesPerSecond, int bytesVerified, int bytesFailed)
{
AfterVerifyBlock(mediaTester, absoluteDataBlockIndex, absoluteDataByteIndex, testFilePath, readBytesPerSecond, bytesVerified, bytesFailed, false);
}

private static void AfterVerifyBlock(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePathlong, long readBytesPerSecond, int bytesVerified, int bytesFailed, bool isQuickTest = false)
{
if (bytesFailed == 0)
{
WriteLog(mediaTester, $"Verified {(isQuickTest ? "quick test " : string.Empty)}block {absoluteDataBlockIndex.ToString("#,##0")}. Byte index: {absoluteDataByteIndex.ToString("#,##0")} / {mediaTester.Options.MaxBytesToTest.ToString("#,##0")}. {(isQuickTest ? string.Empty : readBytesPerSecond.ToString("#,##0") + "B/sec ")}({mediaTester.ProgressPercent.ToString("0.00")}%)");
}
else
{
WriteLog(mediaTester, $"FAILED {(isQuickTest ? "quick test " : string.Empty)}block {absoluteDataBlockIndex.ToString("#,##0")}! Byte index: {absoluteDataByteIndex.ToString("#,##0")} / {mediaTester.Options.MaxBytesToTest.ToString("#,##0")}. {(isQuickTest ? string.Empty : readBytesPerSecond.ToString("#,##0") + "B/sec ")}({mediaTester.ProgressPercent.ToString("0.00")}%)");
}
}

private static void AfterQuickTest(MediaTester mediaTester, long absoluteDataBlockIndex, long absoluteDataByteIndex, string testFilePathlong, long readBytesPerSecond, int bytesVerified, int bytesFailed)
{
AfterVerifyBlock(mediaTester, absoluteDataBlockIndex, absoluteDataByteIndex, testFilePathlong, readBytesPerSecond, bytesVerified, bytesFailed, true);
}

private static void OnMediaTesterException(MediaTester mediaTester, Exception exception)
{
WriteLog(mediaTester, $"{exception.Message}");
if (exception.InnerException != null)
{
OnMediaTesterException(mediaTester, exception.InnerException);
}
}

private static void WriteLog(MediaTester mediaTester, string message)
{
string finalMessage = (mediaTester.IsSuccess ? "No errors" : "FAILURES!") + " - " + message;
Console.WriteLine(finalMessage);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Main());
}
}
}
6 changes: 3 additions & 3 deletions MediaTester/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MediaTester")]
[assembly: AssemblyTitle("MediaTesterGui")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("KrahmerSoft")]
[assembly: AssemblyProduct("MediaTester")]
[assembly: AssemblyProduct("MediaTesterGui")]
[assembly: AssemblyCopyright("Copyright © KrahmerSoft 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
Expand All @@ -20,7 +20,7 @@
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("654fd051-c611-406a-aa97-40d84f41afb1")]
[assembly: Guid("a2a7c26e-7a5c-4f38-a5f3-1d71061ad025")]

// Version information for an assembly consists of the following four values:
//
Expand Down
63 changes: 63 additions & 0 deletions MediaTester/Properties/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
26 changes: 26 additions & 0 deletions MediaTester/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 7e134b8

Please sign in to comment.