Hi Christopher, 

 

Thank you for your response, I had a feeling that this is the way that it 
should be approached. In my case the RPC is fairly straight forward, but 
I’d still like it to be testable, so perhaps using DataFlow blocks as you 
have is suitable. I’ll look into it thanks.


On Tuesday, 7 May 2019 22:35:52 UTC+1, Christopher Warrington - MSFT wrote:
>
> On Tuesday, May 7, 2019 at 1:57:34 AM UTC-7, Joseph Vaughan wrote:
>
> > Does anyone have any good solutions for substituting in the
> > IServerStreamWriter, IClientStreamWriter, IAsyncStreamReader types, 
> either
> > under a mock framework or with test stubs?
>
> In my team's code base, we've divorced the business logic from the gRPC
> handler implementation by using DataFlow [1] blocks. The business logic
> doesn't even contain a reference to the gRPC assemblies at all. It does use
> Proto messages. This makes the business logic easily unit testable.
>
> We have small adapters from the gRPC interfaces to Dataflow blocks. The
> service handlers use these adapters to bridge from IServerStreamWriter &
> friends to the business logic's input/output types. These adapters get
> tested in our server integration tests.
>
> We have four different projects of interest here:
>
> * core (class library): business logic
> * core-tests (unit tests): tests for code in core
> * service (executable): reads config, starts gRPC service, gRPC to business
>   logic adapter (service handlers), Dataflow blocks adapter
> * service-tests (integration tests): stands up full service using 
> single-box
>   config and exercises it
>
> [1]: 
> https://docs.microsoft.com/en-us/dotnet/standard/parallel-programming/dataflow-task-parallel-library
>
> --
> Christopher Warrington
> Microsoft Corp.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"grpc.io" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to grpc-io+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/grpc-io/33f00e7d-395c-489c-97fe-06a0503abd97%40googlegroups.com.

Reply via email to