public async stt::Task UpdateUserFeedbackAsync() { moq::Mock <QuestionService.QuestionServiceClient> mockGrpcClient = new moq::Mock <QuestionService.QuestionServiceClient>(moq::MockBehavior.Strict); UpdateUserFeedbackRequest request = new UpdateUserFeedbackRequest { UserFeedback = new UserFeedback(), UpdateMask = new wkt::FieldMask(), }; UserFeedback expectedResponse = new UserFeedback { UserFeedbackName = UserFeedbackName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"), FreeFormFeedback = "free_form_feedbackab42f4bb", Rating = UserFeedback.Types.UserFeedbackRating.Unspecified, }; mockGrpcClient.Setup(x => x.UpdateUserFeedbackAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <UserFeedback>(stt::Task.FromResult(expectedResponse), null, null, null, null)); QuestionServiceClient client = new QuestionServiceClientImpl(mockGrpcClient.Object, null); UserFeedback responseCallSettings = await client.UpdateUserFeedbackAsync(request.UserFeedback, request.UpdateMask, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); UserFeedback responseCancellationToken = await client.UpdateUserFeedbackAsync(request.UserFeedback, request.UpdateMask, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }
public void ExecuteQuestion() { moq::Mock <QuestionService.QuestionServiceClient> mockGrpcClient = new moq::Mock <QuestionService.QuestionServiceClient>(moq::MockBehavior.Strict); ExecuteQuestionRequest request = new ExecuteQuestionRequest { Name = "name1c9368b0", InterpretationIndex = -988014087, }; Question expectedResponse = new Question { QuestionName = QuestionName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"), Scopes = { "scopes35c99a1e", }, Query = "queryf0c71c1b", DataSourceAnnotations = { "data_source_annotationscbcadb22", }, InterpretError = new InterpretError(), Interpretations = { new Interpretation(), }, CreateTime = new wkt::Timestamp(), UserEmail = "user_emaildc7bc240", DebugFlags = new DebugFlags(), DebugInfo = new wkt::Any(), }; mockGrpcClient.Setup(x => x.ExecuteQuestion(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); QuestionServiceClient client = new QuestionServiceClientImpl(mockGrpcClient.Object, null); Question response = client.ExecuteQuestion(request.Name, request.InterpretationIndex); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void GetUserFeedbackResourceNames() { moq::Mock <QuestionService.QuestionServiceClient> mockGrpcClient = new moq::Mock <QuestionService.QuestionServiceClient>(moq::MockBehavior.Strict); GetUserFeedbackRequest request = new GetUserFeedbackRequest { UserFeedbackName = UserFeedbackName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"), }; UserFeedback expectedResponse = new UserFeedback { UserFeedbackName = UserFeedbackName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"), FreeFormFeedback = "free_form_feedbackab42f4bb", Rating = UserFeedback.Types.UserFeedbackRating.Unspecified, }; mockGrpcClient.Setup(x => x.GetUserFeedback(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); QuestionServiceClient client = new QuestionServiceClientImpl(mockGrpcClient.Object, null); UserFeedback response = client.GetUserFeedback(request.UserFeedbackName); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public async stt::Task GetQuestionRequestObjectAsync() { moq::Mock <QuestionService.QuestionServiceClient> mockGrpcClient = new moq::Mock <QuestionService.QuestionServiceClient>(moq::MockBehavior.Strict); GetQuestionRequest request = new GetQuestionRequest { QuestionName = QuestionName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"), ReadMask = new wkt::FieldMask(), }; Question expectedResponse = new Question { QuestionName = QuestionName.FromProjectLocationQuestion("[PROJECT]", "[LOCATION]", "[QUESTION]"), Scopes = { "scopes35c99a1e", }, Query = "queryf0c71c1b", DataSourceAnnotations = { "data_source_annotationscbcadb22", }, InterpretError = new InterpretError(), Interpretations = { new Interpretation(), }, CreateTime = new wkt::Timestamp(), UserEmail = "user_emaildc7bc240", DebugFlags = new DebugFlags(), DebugInfo = new wkt::Any(), }; mockGrpcClient.Setup(x => x.GetQuestionAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Question>(stt::Task.FromResult(expectedResponse), null, null, null, null)); QuestionServiceClient client = new QuestionServiceClientImpl(mockGrpcClient.Object, null); Question responseCallSettings = await client.GetQuestionAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None)); xunit::Assert.Same(expectedResponse, responseCallSettings); Question responseCancellationToken = await client.GetQuestionAsync(request, st::CancellationToken.None); xunit::Assert.Same(expectedResponse, responseCancellationToken); mockGrpcClient.VerifyAll(); }