You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
We recently stumbled over the issue of testing specific scenarios with the gRPC Channel object.
The issue was simplified (without the project overhead).
Example issue:
publicclassCustomGrpcService{publicCustomGrpcService(){this.GrpcChannel=GrpcChannel.ForAddress("testUri");}publicGrpcChannelGrpcChannel{get;set;}publicvoidDoSomething(){if(this.GrpcChannel.State==ConnectivityState.Idle){// Do Smth}elseif(this.GrpcChannel.State==ConnectivityState.Ready){// Do Smth}elseif(this.GrpcChannel.State==ConnectivityState.Connecting){// Do Smth}elseif(this.GrpcChannel.State==ConnectivityState.TransientFailure){// Do Smth}elseif(this.GrpcChannel.State==ConnectivityState.Shutdown){// Do Smth}}}
Example tests:
[Fact]publicvoidTestIdleBehaiour(){CustomGrpcServicecustomGrpcService=newCustomGrpcService();customGrpcService.DoSomething();// Assert result in some way}[Fact]publicvoidTestReadyBehaiour(){CustomGrpcServicecustomGrpcService=newCustomGrpcService();customGrpcService.DoSomething();// Assert result in some way}
....
As of now, we have no possibility to change the behavior of the channel. Also, we would like to test this kind of functionality without acquiring a real OS port.
Mocking is unfortunately not an option, due to the class GrpcChannel being sealed.
Describe the solution you'd like
I would like a possibility to abstract the GrpcChannel object in some way.
Define interface to decouple functionallity from implementation
Remove the sealed keyword from the 'GrpcChannel' to allow a mock implementation.
Additional context
I believe that some applications could really benefit from this functionality. If it fits into the current project architecture, I would be glad to contribute.
Best
Fabian
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
We recently stumbled over the issue of testing specific scenarios with the gRPC Channel object.
The issue was simplified (without the project overhead).
Example issue:
Example tests:
As of now, we have no possibility to change the behavior of the channel. Also, we would like to test this kind of functionality without acquiring a real OS port.
Mocking is unfortunately not an option, due to the class
GrpcChannel
being sealed.Describe the solution you'd like
I would like a possibility to abstract the GrpcChannel object in some way.
Define interface to decouple functionallity from implementation
Open up sealed class
Remove the sealed keyword from the 'GrpcChannel' to allow a mock implementation.
Additional context
I believe that some applications could really benefit from this functionality. If it fits into the current project architecture, I would be glad to contribute.
Best
Fabian
The text was updated successfully, but these errors were encountered: