/// <summary>Snippet for GetMessage</summary>
 public void GetMessageResourceNames()
 {
     // Snippet: GetMessage(MessageName, CallSettings)
     // Create client
     MessagesClient messagesClient = MessagesClient.Create();
     // Initialize request argument(s)
     MessageName name = MessageName.FromProjectMessage("[PROJECT]", "[MESSAGE]");
     // Make the request
     Message response = messagesClient.GetMessage(name);
     // End snippet
 }
Esempio n. 2
0
        public async stt::Task CreateMessageRequestObjectAsync()
        {
            moq::Mock <Messages.MessagesClient> mockGrpcClient = new moq::Mock <Messages.MessagesClient>(moq::MockBehavior.Strict);
            CreateMessageRequest request = new CreateMessageRequest
            {
                ParentAsProjectName = ProjectName.FromProject("[PROJECT]"),
                Message             = new Message(),
            };
            Message expectedResponse = new Message
            {
                MessageName           = MessageName.FromProjectMessage("[PROJECT]", "[MESSAGE]"),
                To                    = "to03e2b601",
                From                  = "fromf8078ad9",
                Body                  = "body682d1a84",
                StatusUpdateUrl       = "status_update_url6240cc54",
                ReplyUrl              = "reply_urla9dcb82b",
                ValidityPeriodSeconds = 1525204720,
                SmartEncoding         = true,
                Direction             = Message.Types.Direction.Incoming,
                ErrorCode             = "error_code42bd958e",
                ErrorMessage          = "error_messaged73952bd",
                SegmentCount          = 45476232,
                Price                 = new gt::Money(),
                Status                = Message.Types.Status.Sending,
                CreateIdentity        = "create_identityc92d734f",
                CreateTime            = new wkt::Timestamp(),
                SendTime              = new wkt::Timestamp(),
                DeliverTime           = new wkt::Timestamp(),
                Labels                =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Classification             = Message.Types.MessageClassification.Marketing,
                UnsubscribeContentBehavior = Message.Types.UnsubscribeContentBehavior.AppendUrl,
                Encoding = Message.Types.MessageEncoding.Gsm7,
            };

            mockGrpcClient.Setup(x => x.CreateMessageAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <Message>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            MessagesClient client = new MessagesClientImpl(mockGrpcClient.Object, null);
            Message        responseCallSettings = await client.CreateMessageAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            Message responseCancellationToken = await client.CreateMessageAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        /// <summary>Snippet for GetMessageAsync</summary>
        public async Task GetMessageResourceNamesAsync()
        {
            // Snippet: GetMessageAsync(MessageName, CallSettings)
            // Additional: GetMessageAsync(MessageName, CancellationToken)
            // Create client
            MessagesClient messagesClient = await MessagesClient.CreateAsync();

            // Initialize request argument(s)
            MessageName name = MessageName.FromProjectMessage("[PROJECT]", "[MESSAGE]");
            // Make the request
            Message response = await messagesClient.GetMessageAsync(name);

            // End snippet
        }
 /// <summary>Snippet for GetMessage</summary>
 public void GetMessageRequestObject()
 {
     // Snippet: GetMessage(GetMessageRequest, CallSettings)
     // Create client
     MessagesClient messagesClient = MessagesClient.Create();
     // Initialize request argument(s)
     GetMessageRequest request = new GetMessageRequest
     {
         MessageName = MessageName.FromProjectMessage("[PROJECT]", "[MESSAGE]"),
     };
     // Make the request
     Message response = messagesClient.GetMessage(request);
     // End snippet
 }