public async stt::Task DismissRecommendationAsync() { moq::Mock <RecommendationService.RecommendationServiceClient> mockGrpcClient = new moq::Mock <RecommendationService.RecommendationServiceClient>(moq::MockBehavior.Strict); DismissRecommendationRequest request = new DismissRecommendationRequest { CustomerId = "customer_id3b3724cb", Operations = { new DismissRecommendationRequest.Types.DismissRecommendationOperation(), }, }; DismissRecommendationResponse expectedResponse = new DismissRecommendationResponse { Results = { new DismissRecommendationResponse.Types.DismissRecommendationResult(), }, PartialFailureError = new gr::Status(), }; mockGrpcClient.Setup(x => x.DismissRecommendationAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <DismissRecommendationResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); RecommendationServiceClient client = new RecommendationServiceClientImpl(mockGrpcClient.Object, null); DismissRecommendationResponse responseCallSettings = await client.DismissRecommendationAsync(request.CustomerId, request.Operations, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); Assert.AreEqual(expectedResponse, responseCallSettings); DismissRecommendationResponse responseCancellationToken = await client.DismissRecommendationAsync(request.CustomerId, request.Operations, st::CancellationToken.None); Assert.AreEqual(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task DismissRecommendationAsync3() { Mock <RecommendationService.RecommendationServiceClient> mockGrpcClient = new Mock <RecommendationService.RecommendationServiceClient>(MockBehavior.Strict); DismissRecommendationRequest request = new DismissRecommendationRequest { CustomerId = "customerId-1772061412", Operations = { }, }; DismissRecommendationResponse expectedResponse = new DismissRecommendationResponse(); mockGrpcClient.Setup(x => x.DismissRecommendationAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <DismissRecommendationResponse>(Task.FromResult(expectedResponse), null, null, null, null)); RecommendationServiceClient client = new RecommendationServiceClientImpl(mockGrpcClient.Object, null); DismissRecommendationResponse response = await client.DismissRecommendationAsync(request); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task DismissRecommendationAsync() { Mock <RecommendationService.RecommendationServiceClient> mockGrpcClient = new Mock <RecommendationService.RecommendationServiceClient>(MockBehavior.Strict); DismissRecommendationRequest expectedRequest = new DismissRecommendationRequest { CustomerId = "customerId-1772061412", PartialFailure = true, Operations = { }, }; DismissRecommendationResponse expectedResponse = new DismissRecommendationResponse(); mockGrpcClient.Setup(x => x.DismissRecommendationAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <DismissRecommendationResponse>(Task.FromResult(expectedResponse), null, null, null, null)); RecommendationServiceClient client = new RecommendationServiceClientImpl(mockGrpcClient.Object, null); string customerId = "customerId-1772061412"; bool partialFailure = true; IEnumerable <DismissRecommendationRequest.Types.DismissRecommendationOperation> operations = new List <DismissRecommendationRequest.Types.DismissRecommendationOperation>(); DismissRecommendationResponse response = await client.DismissRecommendationAsync(customerId, partialFailure, operations); Assert.AreEqual(expectedResponse, response); mockGrpcClient.VerifyAll(); }