-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Tests,GrpcClient,GrpcServer: made e2e GRPC test
Made end-to-end GRPC test that makes sure GRPC communication is working.
- Loading branch information
1 parent
94a7801
commit 2ee88ec
Showing
4 changed files
with
64 additions
and
3 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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Threading.Tasks; | ||
using FsharpExchangeDotNetStandard; | ||
|
||
using NUnit.Framework; | ||
using StackExchange.Redis; | ||
|
||
namespace FsharpExchange.Tests | ||
{ | ||
[TestFixture] | ||
public class E2ETests | ||
{ | ||
private Process LaunchGrpcServer() | ||
{ | ||
var solutionDir = (new DirectoryInfo(Environment.CurrentDirectory)).Parent?.Parent?.Parent?.Parent?.Parent; | ||
var serviceExeDir = Path.Join(solutionDir.FullName, "src", "FX.GrpcService", "bin", "Debug", "net8.0"); | ||
|
||
var argsString = $"--urls http://localhost:{GrpcClient.Instance.Port}"; | ||
|
||
if (OperatingSystem.IsWindows()) | ||
{ | ||
var serviceExePath = Path.Join(serviceExeDir, "FX.GrpcService.exe"); | ||
return Process.Start(serviceExePath, argsString); | ||
} | ||
else | ||
{ | ||
var processInfo = new ProcessStartInfo | ||
{ | ||
UseShellExecute = false, | ||
CreateNoWindow = true, | ||
FileName = "dotnet", | ||
Arguments = Path.Join(serviceExeDir, "FX.GrpcService.dll") + " " + argsString | ||
}; | ||
return Process.Start(processInfo); | ||
} | ||
} | ||
|
||
[Test] | ||
async public Task GrpcE2ETest() | ||
{ | ||
using var serverProcess = LaunchGrpcServer(); | ||
await Task.Delay(TimeSpan.FromSeconds(1.0)); | ||
|
||
var client = new GrpcClient.Instance(); | ||
client.Connect(); | ||
|
||
var message = "hello"; | ||
var response = await client.SendMessage(message); | ||
|
||
Assert.That(response, Is.EqualTo("received " + message)); | ||
} | ||
} | ||
} |
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