Skip to content

Commit

Permalink
#107 fix cross platform file name
Browse files Browse the repository at this point in the history
  • Loading branch information
maythamfahmi committed Oct 21, 2024
1 parent b3b7ad9 commit b4d7e4f
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 18 deletions.
21 changes: 13 additions & 8 deletions Examples/Examples.UnitTests/AESExampleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ namespace CryptoNet.Examples.UnitTests;
[TestFixture]
public class AESExampleTests : ExampleTestBase
{
private const string AESExampleExeName = "AESExample.exe";

//[Ignore("temp")]
[Test]
public async Task AESExampleSmokeTest()
{
// ToDo: Missing executables on Linux and MacOS.
if (Environment.OSVersion.Platform != PlatformID.Win32NT) return;
string aesExampleExeName;

if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
aesExampleExeName = "AESExample.exe"; // Windows executable
}
else
{
aesExampleExeName = "AESExample"; // Linux or MacOs executable
}

// This provides a human readable temporary directory name prefix.
// If you see a lot of these laying around your temp directory, it's
Expand All @@ -28,11 +33,11 @@ public async Task AESExampleSmokeTest()
using (var tmpDir = new TempDirectory(tmpDirPrefix))
{
ClassicAssert.IsTrue(Directory.Exists(tmpDir.DirectoryInfo.FullName));
ClassicAssert.IsTrue(File.Exists(AESExampleExeName));
ClassicAssert.IsTrue(File.Exists(aesExampleExeName));

ShowAvailableExecutables();
ShowAvailableExecutables(aesExampleExeName);

var result = await Cli.Wrap(AESExampleExeName)
var result = await Cli.Wrap(aesExampleExeName)
.WithWorkingDirectory(tmpDir.DirectoryInfo.FullName)
.WithStandardOutputPipe(PipeTarget.ToStringBuilder(stdOutBuffer))
.WithStandardErrorPipe(PipeTarget.ToStringBuilder(stdErrBuffer))
Expand Down
4 changes: 2 additions & 2 deletions Examples/Examples.UnitTests/ExampleTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ namespace CryptoNet.Examples.UnitTests;

public class ExampleTestBase
{
public void ShowAvailableExecutables()
public void ShowAvailableExecutables(string filename)
{
Console.WriteLine("Available .exe files in CWD:");
foreach (var fileName in Directory.GetFiles(".", "*.exe"))
foreach (var fileName in Directory.GetFiles(".", filename))
{
Console.WriteLine(fileName);
}
Expand Down
21 changes: 13 additions & 8 deletions Examples/Examples.UnitTests/RSAExampleTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ namespace CryptoNet.Examples.UnitTests;
[TestFixture]
public class RSAExampleTests : ExampleTestBase
{
private const string RSAExampleExeName = "RSAExample.exe";

//[Ignore("temp")]
[Test]
public async Task RSAExampleSmokeTest()
{
// ToDo: Missing executables on Linux and MacOS.
if (Environment.OSVersion.Platform != PlatformID.Win32NT) return;
string rsaExampleExeName;

if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
rsaExampleExeName = "RSAExample.exe"; // Windows executable
}
else
{
rsaExampleExeName = "RSAExample"; // Linux or MacOs executable
}

var tmpDirPrefix = $"{nameof(AESExampleTests)}.{nameof(RSAExampleSmokeTest)}-{Guid.NewGuid().ToString("D")}";

Expand All @@ -25,11 +30,11 @@ public async Task RSAExampleSmokeTest()
using (var tmpDir = new TempDirectory())
{
ClassicAssert.IsTrue(Directory.Exists(tmpDir.DirectoryInfo.FullName));
ClassicAssert.IsTrue(File.Exists(RSAExampleExeName));
ClassicAssert.IsTrue(File.Exists(rsaExampleExeName));

ShowAvailableExecutables();
ShowAvailableExecutables(rsaExampleExeName);

var result = await Cli.Wrap(RSAExampleExeName)
var result = await Cli.Wrap(rsaExampleExeName)
.WithWorkingDirectory(tmpDir.DirectoryInfo.FullName)
.WithStandardOutputPipe(PipeTarget.ToStringBuilder(stdOutBuffer))
.WithStandardErrorPipe(PipeTarget.ToStringBuilder(stdErrBuffer))
Expand Down

0 comments on commit b4d7e4f

Please sign in to comment.