예제 #1
0
        /// <summary>Snippet for SendTestMessage</summary>
        public void SendTestMessageRequestObject()
        {
            // Snippet: SendTestMessage(SendTestMessageRequest, CallSettings)
            // Create client
            EssentialContactsServiceClient essentialContactsServiceClient = EssentialContactsServiceClient.Create();
            // Initialize request argument(s)
            SendTestMessageRequest request = new SendTestMessageRequest
            {
                ContactsAsContactNames =
                {
                    ContactName.FromProjectContact("[PROJECT]", "[CONTACT]"),
                },
                ResourceAsProjectName = ProjectName.FromProject("[PROJECT]"),
                NotificationCategory  = NotificationCategory.Unspecified,
            };

            // Make the request
            essentialContactsServiceClient.SendTestMessage(request);
            // End snippet
        }
        public void SendTestMessageRequestObject()
        {
            moq::Mock <EssentialContactsService.EssentialContactsServiceClient> mockGrpcClient = new moq::Mock <EssentialContactsService.EssentialContactsServiceClient>(moq::MockBehavior.Strict);
            SendTestMessageRequest request = new SendTestMessageRequest
            {
                ContactsAsContactNames =
                {
                    ContactName.FromProjectContact("[PROJECT]", "[CONTACT]"),
                },
                ResourceAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"),
                NotificationCategory  = NotificationCategory.All,
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.SendTestMessage(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            EssentialContactsServiceClient client = new EssentialContactsServiceClientImpl(mockGrpcClient.Object, null);

            client.SendTestMessage(request);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task SendTestMessageRequestObjectAsync()
        {
            moq::Mock <EssentialContactsService.EssentialContactsServiceClient> mockGrpcClient = new moq::Mock <EssentialContactsService.EssentialContactsServiceClient>(moq::MockBehavior.Strict);
            SendTestMessageRequest request = new SendTestMessageRequest
            {
                ContactsAsContactNames =
                {
                    ContactName.FromProjectContact("[PROJECT]", "[CONTACT]"),
                },
                ResourceAsProjectName = gagr::ProjectName.FromProject("[PROJECT]"),
                NotificationCategory  = NotificationCategory.All,
            };
            wkt::Empty expectedResponse = new wkt::Empty {
            };

            mockGrpcClient.Setup(x => x.SendTestMessageAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <wkt::Empty>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            EssentialContactsServiceClient client = new EssentialContactsServiceClientImpl(mockGrpcClient.Object, null);
            await client.SendTestMessageAsync(request, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            await client.SendTestMessageAsync(request, st::CancellationToken.None);

            mockGrpcClient.VerifyAll();
        }