Skip to content

Commit

Permalink
Merge pull request #4 from madelson/short-flush-fix
Browse files Browse the repository at this point in the history
Short flush fix
  • Loading branch information
madelson committed Jul 12, 2015
2 parents 96b4d27 + aace803 commit 3cf74ff
Show file tree
Hide file tree
Showing 16 changed files with 1,512 additions and 743 deletions.
35 changes: 35 additions & 0 deletions MedallionShell.Tests/GeneralTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,41 @@ public void TestVersioning()
version.ShouldEqual(informationalVersion.InformationalVersion + ".0");
}

[TestMethod]
public void TestShortFlush()
{
var command = Command.Run("SampleCommand", "shortflush", "a");
var readCommand = command.StandardOutput.ReadBlockAsync(new char[1], 0, 1);
//var readCommand = command.StandardOutput.BaseStream.ReadAsync(new byte[1], 0, 1);
readCommand.Wait(TimeSpan.FromSeconds(5)).ShouldEqual(true);

command.StandardInput.Close();
command.Task.Wait(TimeSpan.FromSeconds(5)).ShouldEqual(true);
}

[TestMethod]
public void TestAutoFlush()
{
var command = Command.Run("SampleCommand", "echo", "--per-char");
command.StandardInput.AutoFlush.ShouldEqual(true);
command.StandardInput.Write('a');

var buffer = new char[1];
var asyncRead = command.StandardOutput.ReadBlockAsync(buffer, 0, 1);
asyncRead.Wait(TimeSpan.FromSeconds(3)).ShouldEqual(true);
buffer[0].ShouldEqual('a');

command.StandardInput.AutoFlush = false;
command.StandardInput.Write('b');
asyncRead = command.StandardOutput.ReadBlockAsync(buffer, 0, 1);
asyncRead.Wait(TimeSpan.FromSeconds(.01)).ShouldEqual(false);
command.StandardInput.Flush();
asyncRead.Wait(TimeSpan.FromSeconds(3)).ShouldEqual(true);
buffer[0].ShouldEqual('b');

command.StandardInput.Close();
}

[TestMethod]
public void TestErrorEcho()
{
Expand Down
1 change: 1 addition & 0 deletions MedallionShell.Tests/MedallionShell.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<Compile Include="GeneralTest.cs" />
<Compile Include="PipeTest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Streams\PipeTest.cs" />
<Compile Include="SyntaxTest.cs" />
<Compile Include="UnitTestHelpers.cs" />
</ItemGroup>
Expand Down
Loading

0 comments on commit 3cf74ff

Please sign in to comment.