Net.Testing.Moq.Grpc 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Net.Testing.Moq.Grpc --version 1.0.0                
NuGet\Install-Package Net.Testing.Moq.Grpc -Version 1.0.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Net.Testing.Moq.Grpc" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Net.Testing.Moq.Grpc --version 1.0.0                
#r "nuget: Net.Testing.Moq.Grpc, 1.0.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Net.Testing.Moq.Grpc as a Cake Addin
#addin nuget:?package=Net.Testing.Moq.Grpc&version=1.0.0

// Install Net.Testing.Moq.Grpc as a Cake Tool
#tool nuget:?package=Net.Testing.Moq.Grpc&version=1.0.0                

grpc.net.testing.moq

.NET

Library to mocking gRPC client. Instead of Grpc.Core.Testing using extensions for Moq

Based on libraries:

Using example

Simple sync calling:

// Creation moq
var grpcMock = new Mock<TestService.TestServiceClient>();
// Setup and set return
grpcMock
    .Setup(c => c.Simple(It.IsAny<TestRequest>(), null, null, default))
    .Returns(new TestResponse());

var client = grpcMock.Object;

// Call
var response = client.Simple(new TestRequest());

Simple async calling:

// Creation moq
var grpcMock = new Mock<TestService.TestServiceClient>();
var testResponse = new TestResponse();

// Setup and set response like second argument
grpcMock.Setup(c => c.SimpleAsync(It.IsAny<TestRequest>(), null, null, default), testResponse);

var client = grpcMock.Object;

// Call
var response = await client.SimpleAsync(new TestRequest());

Simple client stream calling:

// Creation moq
var grpcMock = new Mock<TestService.TestServiceClient>();
var testResponse = new TestResponse();

// Setup and set response like second argument
grpcMock.Setup(c => c.SimpleClientStream(null, null, default), testResponse);

var client = grpcMock.Object;

// Call
var stream = client.SimpleClientStream();
await stream.RequestStream.WriteAllAsync(new[] {new TestRequest()});
var response = await stream;

Simple server stream calling:

// Creation moq
var grpcMock = new Mock<TestService.TestServiceClient>();
var testResponse = new TestResponse();

// Setup and set responses like second argument (params TResponse[] responses)
grpcMock.Setup(c => c.SimpleServerStream(It.IsAny<TestRequest>(), null, null, default), testResponse);

var client = grpcMock.Object;

// Call
var stream = client.SimpleServerStream(new TestRequest());
var responses = stream.ResponseStream.ReadAllAsync();

Simple client server streams calling:

// Creation moq
var grpcMock = new Mock<TestService.TestServiceClient>();
var testResponse = new TestResponse();

// Setup and set responses like second argument (params TResponse[] responses)
grpcMock.Setup(c => c.SimpleClientServerStream(null, null, default), testResponse);

var client = grpcMock.Object;

// Call
var stream = client.SimpleClientServerStream();
await stream.RequestStream.WriteAsync(new TestRequest());
var responses = stream.ResponseStream.ReadAllAsync();
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.3.0 5,101 11/14/2023
1.2.1 1,108 10/1/2023
1.2.0 172 10/1/2023
1.1.1 42,497 4/20/2022
1.1.0 797 1/14/2022
1.0.1 839 11/4/2021
1.0.0 374 11/4/2021