-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GD-127: Replace stdout based TestEventProcessor by IPC implementation (…
…#129) # Why see #127 # What - renamed project file to the real name `gdUnit4Net` - introduced IPC for test event reporting - increase api version to 4.3.0 - increase adapter version to 2.0.0
- Loading branch information
1 parent
cb66317
commit 8f8327b
Showing
20 changed files
with
682 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,3 +23,4 @@ mono_crash.*.json | |
|
||
.fake | ||
.ionide | ||
gdUnit4Net.sln.DotSettings.user |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,50 @@ | ||
namespace GdUnit4.Api; | ||
|
||
using System; | ||
using System.IO; | ||
using System.IO.Pipes; | ||
using System.Security.Principal; | ||
|
||
using Newtonsoft.Json; | ||
|
||
internal class TestAdapterReporter : ITestEventListener | ||
{ | ||
public const string PipeName = "gdunit4-event-pipe"; | ||
private readonly NamedPipeClientStream client; | ||
private readonly StreamWriter? writer; | ||
|
||
public TestAdapterReporter() | ||
{ | ||
client = new NamedPipeClientStream(".", PipeName, PipeDirection.Out, PipeOptions.Asynchronous, TokenImpersonationLevel.Impersonation); | ||
if (!client.IsConnected) | ||
try | ||
{ | ||
Console.WriteLine("Try to connect to GdUnit4 test report server!"); | ||
client.Connect(TimeSpan.FromSeconds(5)); | ||
writer = new StreamWriter(client) { AutoFlush = true }; | ||
writer.WriteLine("TestAdapterReporter: Successfully connected to GdUnit4 test report server!"); | ||
} | ||
catch (TimeoutException e) | ||
{ | ||
Console.Error.WriteLine(e); | ||
throw; | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
writer?.WriteLine("TestAdapterReporter: Disconnecting from GdUnit4 test report server."); | ||
writer?.Dispose(); | ||
client.Dispose(); | ||
} | ||
|
||
public bool IsFailed { get; set; } | ||
|
||
public void PublishEvent(TestEvent e) | ||
{ | ||
if (e.IsFailed || e.IsError) | ||
IsFailed = true; | ||
var json = JsonConvert.SerializeObject(e); | ||
Console.WriteLine($"GdUnitTestEvent:{json}"); | ||
writer!.WriteLine($"GdUnitTestEvent:{json}"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.