Enhanced.Testing.Component.GrpcClient
1.6.0
dotnet add package Enhanced.Testing.Component.GrpcClient --version 1.6.0
NuGet\Install-Package Enhanced.Testing.Component.GrpcClient -Version 1.6.0
<PackageReference Include="Enhanced.Testing.Component.GrpcClient" Version="1.6.0" />
<PackageVersion Include="Enhanced.Testing.Component.GrpcClient" Version="1.6.0" />
<PackageReference Include="Enhanced.Testing.Component.GrpcClient" />
paket add Enhanced.Testing.Component.GrpcClient --version 1.6.0
#r "nuget: Enhanced.Testing.Component.GrpcClient, 1.6.0"
#:package Enhanced.Testing.Component.GrpcClient@1.6.0
#addin nuget:?package=Enhanced.Testing.Component.GrpcClient&version=1.6.0
#tool nuget:?package=Enhanced.Testing.Component.GrpcClient&version=1.6.0
Enhanced.Testing.Component.GrpcClient
A gRPC client harness for Enhanced.Testing.Component:
creates generated gRPC clients that call the application in memory through TestServer, without opening network
ports.
dotnet add package Enhanced.Testing.Component.GrpcClient
Usage
var grpc = new GrpcClientHarness();
var component = ComponentBuilder.Create<Program>()
.AddHarness(grpc)
.Build();
In a test, create any client generated from your .proto files:
var client = grpc.CreateClient<Greeter.GreeterClient>();
var reply = await client.SayHelloAsync(new HelloRequest { Name = "John" });
Assert.Equal("Hello John", reply.Message);
The harness creates one channel per client type and shuts the channels down when the component stops.
The test project usually references the service project, so generate the client there, next to the server code, and use it from the tests:
<ItemGroup>
<Protobuf Include="Protos\greet.proto" GrpcServices="Both" />
</ItemGroup>
Don't generate the same .proto file again in the test project: the generated types would exist twice and the build
reports CS0436 conflicts. If the test project doesn't reference the service project, generate the client there
instead (GrpcServices="Client", with the Grpc.Tools and Google.Protobuf packages, or Grpc.AspNetCore, which
includes both).
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. net11.0 is compatible. |
-
net10.0
- Enhanced.Testing.Component (>= 1.6.0)
- Grpc.Net.Client (>= 2.85.0)
-
net11.0
- Enhanced.Testing.Component (>= 1.6.0)
- Grpc.Net.Client (>= 2.85.0)
-
net8.0
- Enhanced.Testing.Component (>= 1.6.0)
- Grpc.Net.Client (>= 2.85.0)
-
net9.0
- Enhanced.Testing.Component (>= 1.6.0)
- Grpc.Net.Client (>= 2.85.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.