示例#1
0
        public void MarkRecommendationSucceeded_ResourceNames()
        {
            moq::Mock <Recommender.RecommenderClient> mockGrpcClient = new moq::Mock <Recommender.RecommenderClient>(moq::MockBehavior.Strict);
            MarkRecommendationSucceededRequest        request        = new MarkRecommendationSucceededRequest
            {
                RecommendationName = new RecommendationName("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"),
                StateMetadata      =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Etag = "etage8ad7218",
            };
            Recommendation expectedResponse = new Recommendation
            {
                RecommendationName = new RecommendationName("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"),
                Description        = "description2cf9da67",
                LastRefreshTime    = new wkt::Timestamp(),
                PrimaryImpact      = new Impact(),
                AdditionalImpact   = { new Impact(), },
                Content            = new RecommendationContent(),
                StateInfo          = new RecommendationStateInfo(),
                Etag = "etage8ad7218",
                RecommenderSubtype = "recommender_subtype6a5b10f9",
            };

            mockGrpcClient.Setup(x => x.MarkRecommendationSucceeded(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            RecommenderClient client   = new RecommenderClientImpl(mockGrpcClient.Object, null);
            Recommendation    response = client.MarkRecommendationSucceeded(request.RecommendationName, request.StateMetadata, request.Etag);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 /// <summary>Snippet for MarkRecommendationSucceeded</summary>
 public void MarkRecommendationSucceeded_RequestObject()
 {
     // Snippet: MarkRecommendationSucceeded(MarkRecommendationSucceededRequest, CallSettings)
     // Create client
     RecommenderClient recommenderClient = RecommenderClient.Create();
     // Initialize request argument(s)
     MarkRecommendationSucceededRequest request = new MarkRecommendationSucceededRequest
     {
         RecommendationName = new RecommendationName("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"),
         StateMetadata      = { { "", "" }, },
         Etag = "",
     };
     // Make the request
     Recommendation response = recommenderClient.MarkRecommendationSucceeded(request);
     // End snippet
 }
        /// <summary>Snippet for MarkRecommendationSucceededAsync</summary>
        public async Task MarkRecommendationSucceededAsync_RequestObject()
        {
            // Snippet: MarkRecommendationSucceededAsync(MarkRecommendationSucceededRequest, CallSettings)
            // Additional: MarkRecommendationSucceededAsync(MarkRecommendationSucceededRequest, CancellationToken)
            // Create client
            RecommenderClient recommenderClient = await RecommenderClient.CreateAsync();

            // Initialize request argument(s)
            MarkRecommendationSucceededRequest request = new MarkRecommendationSucceededRequest
            {
                RecommendationName = new RecommendationName("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"),
                StateMetadata      = { { "", "" }, },
                Etag = "",
            };
            // Make the request
            Recommendation response = await recommenderClient.MarkRecommendationSucceededAsync(request);

            // End snippet
        }
示例#4
0
        public async stt::Task MarkRecommendationSucceededAsync()
        {
            moq::Mock <Recommender.RecommenderClient> mockGrpcClient = new moq::Mock <Recommender.RecommenderClient>(moq::MockBehavior.Strict);
            MarkRecommendationSucceededRequest        request        = new MarkRecommendationSucceededRequest
            {
                RecommendationName = new RecommendationName("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"),
                StateMetadata      =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Etag = "etage8ad7218",
            };
            Recommendation expectedResponse = new Recommendation
            {
                RecommendationName = new RecommendationName("[PROJECT]", "[LOCATION]", "[RECOMMENDER]", "[RECOMMENDATION]"),
                Description        = "description2cf9da67",
                LastRefreshTime    = new wkt::Timestamp(),
                PrimaryImpact      = new Impact(),
                AdditionalImpact   = { new Impact(), },
                Content            = new RecommendationContent(),
                StateInfo          = new RecommendationStateInfo(),
                Etag = "etage8ad7218",
                RecommenderSubtype = "recommender_subtype6a5b10f9",
            };

            mockGrpcClient.Setup(x => x.MarkRecommendationSucceededAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Recommendation>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            RecommenderClient client = new RecommenderClientImpl(mockGrpcClient.Object, null);
            Recommendation    responseCallSettings = await client.MarkRecommendationSucceededAsync(request.Name, request.StateMetadata, request.Etag, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Recommendation responseCancellationToken = await client.MarkRecommendationSucceededAsync(request.Name, request.StateMetadata, request.Etag, st::CancellationToken.None);

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