public async stt::Task AnnotateAssessmentResourceNamesAsync() { moq::Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client> mockGrpcClient = new moq::Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client>(moq::MockBehavior.Strict); AnnotateAssessmentRequest request = new AnnotateAssessmentRequest { AssessmentName = AssessmentName.FromProjectAssessment("[PROJECT]", "[ASSESSMENT]"), Annotation = AnnotateAssessmentRequest.Types.Annotation.Legitimate, }; AnnotateAssessmentResponse expectedResponse = new AnnotateAssessmentResponse { }; mockGrpcClient.Setup(x => x.AnnotateAssessmentAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <AnnotateAssessmentResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null)); RecaptchaEnterpriseServiceV1Beta1Client client = new RecaptchaEnterpriseServiceV1Beta1ClientImpl(mockGrpcClient.Object, null); AnnotateAssessmentResponse responseCallSettings = await client.AnnotateAssessmentAsync(request.AssessmentName, request.Annotation, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); AnnotateAssessmentResponse responseCancellationToken = await client.AnnotateAssessmentAsync(request.AssessmentName, request.Annotation, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public async Task AnnotateAssessmentAsync2() { Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client> mockGrpcClient = new Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client>(MockBehavior.Strict); AnnotateAssessmentRequest request = new AnnotateAssessmentRequest { AssessmentName = new AssessmentName("[PROJECT]", "[ASSESSMENT]"), Annotation = AnnotateAssessmentRequest.Types.Annotation.Unspecified, }; AnnotateAssessmentResponse expectedResponse = new AnnotateAssessmentResponse(); mockGrpcClient.Setup(x => x.AnnotateAssessmentAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <AnnotateAssessmentResponse>(Task.FromResult(expectedResponse), null, null, null, null)); RecaptchaEnterpriseServiceV1Beta1Client client = new RecaptchaEnterpriseServiceV1Beta1ClientImpl(mockGrpcClient.Object, null); AnnotateAssessmentResponse response = await client.AnnotateAssessmentAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }