public async Task AnnotateAssessmentAsync() { Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client> mockGrpcClient = new Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client>(MockBehavior.Strict); AnnotateAssessmentRequest expectedRequest = new AnnotateAssessmentRequest { AssessmentName = new AssessmentName("[PROJECT]", "[ASSESSMENT]"), Annotation = AnnotateAssessmentRequest.Types.Annotation.Unspecified, }; AnnotateAssessmentResponse expectedResponse = new AnnotateAssessmentResponse(); mockGrpcClient.Setup(x => x.AnnotateAssessmentAsync(expectedRequest, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <AnnotateAssessmentResponse>(Task.FromResult(expectedResponse), null, null, null, null)); RecaptchaEnterpriseServiceV1Beta1Client client = new RecaptchaEnterpriseServiceV1Beta1ClientImpl(mockGrpcClient.Object, null); AssessmentName name = new AssessmentName("[PROJECT]", "[ASSESSMENT]"); AnnotateAssessmentRequest.Types.Annotation annotation = AnnotateAssessmentRequest.Types.Annotation.Unspecified; AnnotateAssessmentResponse response = await client.AnnotateAssessmentAsync(name, annotation); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
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 void CreateAssessment2() { Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client> mockGrpcClient = new Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client>(MockBehavior.Strict); CreateAssessmentRequest request = new CreateAssessmentRequest { ParentAsProjectName = new ProjectName("[PROJECT]"), Assessment = new Assessment(), }; Assessment expectedResponse = new Assessment { Name = "name3373707", Confidence = 8.2925121E7f, }; mockGrpcClient.Setup(x => x.CreateAssessment(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); RecaptchaEnterpriseServiceV1Beta1Client client = new RecaptchaEnterpriseServiceV1Beta1ClientImpl(mockGrpcClient.Object, null); Assessment response = client.CreateAssessment(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async Task CreateAssessmentAsync2() { Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client> mockGrpcClient = new Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client>(MockBehavior.Strict); CreateAssessmentRequest request = new CreateAssessmentRequest { ParentAsProjectName = new ProjectName("[PROJECT]"), Assessment = new Assessment(), }; Assessment expectedResponse = new Assessment { Name = "name3373707", Score = 1.0926453E7f, }; mockGrpcClient.Setup(x => x.CreateAssessmentAsync(request, It.IsAny <CallOptions>())) .Returns(new Grpc.Core.AsyncUnaryCall <Assessment>(Task.FromResult(expectedResponse), null, null, null, null)); RecaptchaEnterpriseServiceV1Beta1Client client = new RecaptchaEnterpriseServiceV1Beta1ClientImpl(mockGrpcClient.Object, null); Assessment response = await client.CreateAssessmentAsync(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetKeyRequestObject() { moq::Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client> mockGrpcClient = new moq::Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client>(moq::MockBehavior.Strict); GetKeyRequest request = new GetKeyRequest { KeyName = KeyName.FromProjectKey("[PROJECT]", "[KEY]"), }; Key expectedResponse = new Key { KeyName = KeyName.FromProjectKey("[PROJECT]", "[KEY]"), DisplayName = "display_name137f65c2", WebSettings = new WebKeySettings(), AndroidSettings = new AndroidKeySettings(), IosSettings = new IOSKeySettings(), }; mockGrpcClient.Setup(x => x.GetKey(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); RecaptchaEnterpriseServiceV1Beta1Client client = new RecaptchaEnterpriseServiceV1Beta1ClientImpl(mockGrpcClient.Object, null); Key response = client.GetKey(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void CreateAssessment() { Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client> mockGrpcClient = new Mock <RecaptchaEnterpriseServiceV1Beta1.RecaptchaEnterpriseServiceV1Beta1Client>(MockBehavior.Strict); CreateAssessmentRequest expectedRequest = new CreateAssessmentRequest { ParentAsProjectName = new ProjectName("[PROJECT]"), Assessment = new Assessment(), }; Assessment expectedResponse = new Assessment { AssessmentName = new AssessmentName("[PROJECT]", "[ASSESSMENT]"), Score = 1.0926453E7f, }; mockGrpcClient.Setup(x => x.CreateAssessment(expectedRequest, It.IsAny <CallOptions>())) .Returns(expectedResponse); RecaptchaEnterpriseServiceV1Beta1Client client = new RecaptchaEnterpriseServiceV1Beta1ClientImpl(mockGrpcClient.Object, null); ProjectName parent = new ProjectName("[PROJECT]"); Assessment assessment = new Assessment(); Assessment response = client.CreateAssessment(parent, assessment); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }