Esempio n. 1
0
        public void MarkRecommendationClaimed_ResourceNames()
        {
            moq::Mock <Recommender.RecommenderClient> mockGrpcClient = new moq::Mock <Recommender.RecommenderClient>(moq::MockBehavior.Strict);
            MarkRecommendationClaimedRequest          request        = new MarkRecommendationClaimedRequest
            {
                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.MarkRecommendationClaimed(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            RecommenderClient client   = new RecommenderClientImpl(mockGrpcClient.Object, null);
            Recommendation    response = client.MarkRecommendationClaimed(request.RecommendationName, request.StateMetadata, request.Etag);

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

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

            // End snippet
        }
Esempio n. 4
0
        public async stt::Task MarkRecommendationClaimedAsync_ResourceNames()
        {
            moq::Mock <Recommender.RecommenderClient> mockGrpcClient = new moq::Mock <Recommender.RecommenderClient>(moq::MockBehavior.Strict);
            MarkRecommendationClaimedRequest          request        = new MarkRecommendationClaimedRequest
            {
                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.MarkRecommendationClaimedAsync(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.MarkRecommendationClaimedAsync(request.RecommendationName, request.StateMetadata, request.Etag, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

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

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