Initial commit: Nix WSL Wrapper project with DDD, Clean Code, and tests

This commit is contained in:
Marek Novák
2026-07-01 02:04:43 +02:00
commit 161eb7d387
22 changed files with 932 additions and 0 deletions
@@ -0,0 +1,52 @@
using System;
using System.IO;
using System.Text;
using NixWslWrapper.Infrastructure.IO;
using NixWslWrapper.Infrastructure.Executors;
using Xunit;
namespace NixWslWrapper.Tests
{
public class InfrastructureTests
{
[Fact]
public void ThreadedStreamCopier_ValidStream_ShouldCopyEntireContent()
{
var content = "Hello, Nix WSL Wrapper! Stream copying should work flawlessly.";
byte[] bytes = Encoding.UTF8.GetBytes(content);
using var input = new MemoryStream(bytes);
using var output = new MemoryStream();
var copier = new ThreadedStreamCopier(64); // small buffer to force multiple reads
copier.Copy(input, output);
byte[] resultBytes = output.ToArray();
string result = Encoding.UTF8.GetString(resultBytes);
Assert.Equal(content, result);
}
[Fact]
public void ProcessBuilder_ValidConfiguration_ShouldBuildCorrectProcessStartInfo()
{
var builder = new ProcessBuilder()
.SetFileName("my-app.exe")
.SetArguments("--arg1 val1")
.RedirectInput(true)
.RedirectOutput(true)
.RedirectError(true)
.UseShellExecute(false)
.CreateNoWindow(true);
var startInfo = builder.Build();
Assert.Equal("my-app.exe", startInfo.FileName);
Assert.Equal("--arg1 val1", startInfo.Arguments);
Assert.True(startInfo.RedirectStandardInput);
Assert.True(startInfo.RedirectStandardOutput);
Assert.True(startInfo.RedirectStandardError);
Assert.False(startInfo.UseShellExecute);
Assert.True(startInfo.CreateNoWindow);
}
}
}