Esempio n. 1
0
        public async stt::Task CreateQuestionResourceNamesAsync()
        {
            moq::Mock <QuestionService.QuestionServiceClient> mockGrpcClient = new moq::Mock <QuestionService.QuestionServiceClient>(moq::MockBehavior.Strict);
            CreateQuestionRequest request = new CreateQuestionRequest
            {
                ParentAsLocationName = gagr::LocationName.FromProjectLocation("[PROJECT]", "[LOCATION]"),
                Question             = new Question(),
            };
            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.CreateQuestionAsync(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.CreateQuestionAsync(request.ParentAsLocationName, request.Question, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Question responseCancellationToken = await client.CreateQuestionAsync(request.ParentAsLocationName, request.Question, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }