public async Task CreateNotificationChannelAsync()
        {
            Mock <NotificationChannelService.NotificationChannelServiceClient> mockGrpcClient = new Mock <NotificationChannelService.NotificationChannelServiceClient>(MockBehavior.Strict);
            CreateNotificationChannelRequest expectedRequest = new CreateNotificationChannelRequest
            {
                ProjectName         = new ProjectName("[PROJECT]"),
                NotificationChannel = new NotificationChannel(),
            };
            NotificationChannel expectedResponse = new NotificationChannel
            {
                Type        = "type3575610",
                Name        = "name2-1052831874",
                DisplayName = "displayName1615086568",
                Description = "description-1724546052",
            };

            mockGrpcClient.Setup(x => x.CreateNotificationChannelAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <NotificationChannel>(Task.FromResult(expectedResponse), null, null, null, null));
            NotificationChannelServiceClient client = new NotificationChannelServiceClientImpl(mockGrpcClient.Object, null);
            ProjectName         name = new ProjectName("[PROJECT]");
            NotificationChannel notificationChannel = new NotificationChannel();
            NotificationChannel response            = await client.CreateNotificationChannelAsync(name, notificationChannel);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Example #2
0
 /// <summary>Snippet for CreateNotificationChannel</summary>
 public void CreateNotificationChannel_RequestObject()
 {
     // Snippet: CreateNotificationChannel(CreateNotificationChannelRequest,CallSettings)
     // Create client
     NotificationChannelServiceClient notificationChannelServiceClient = NotificationChannelServiceClient.Create();
     // Initialize request argument(s)
     CreateNotificationChannelRequest request = new CreateNotificationChannelRequest
     {
         ProjectName         = new ProjectName("[PROJECT]"),
         NotificationChannel = new NotificationChannel(),
     };
     // Make the request
     NotificationChannel response = notificationChannelServiceClient.CreateNotificationChannel(request);
     // End snippet
 }
Example #3
0
        /// <summary>Snippet for CreateNotificationChannelAsync</summary>
        public async Task CreateNotificationChannelAsync_RequestObject()
        {
            // Snippet: CreateNotificationChannelAsync(CreateNotificationChannelRequest,CallSettings)
            // Additional: CreateNotificationChannelAsync(CreateNotificationChannelRequest,CancellationToken)
            // Create client
            NotificationChannelServiceClient notificationChannelServiceClient = await NotificationChannelServiceClient.CreateAsync();

            // Initialize request argument(s)
            CreateNotificationChannelRequest request = new CreateNotificationChannelRequest
            {
                ProjectName         = new ProjectName("[PROJECT]"),
                NotificationChannel = new NotificationChannel(),
            };
            // Make the request
            NotificationChannel response = await notificationChannelServiceClient.CreateNotificationChannelAsync(request);

            // End snippet
        }
        public void CreateNotificationChannel2()
        {
            Mock <NotificationChannelService.NotificationChannelServiceClient> mockGrpcClient = new Mock <NotificationChannelService.NotificationChannelServiceClient>(MockBehavior.Strict);
            CreateNotificationChannelRequest request = new CreateNotificationChannelRequest
            {
                ProjectName         = new ProjectName("[PROJECT]"),
                NotificationChannel = new NotificationChannel(),
            };
            NotificationChannel expectedResponse = new NotificationChannel
            {
                Type        = "type3575610",
                Name        = "name2-1052831874",
                DisplayName = "displayName1615086568",
                Description = "description-1724546052",
            };

            mockGrpcClient.Setup(x => x.CreateNotificationChannel(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            NotificationChannelServiceClient client = new NotificationChannelServiceClientImpl(mockGrpcClient.Object, null);
            NotificationChannel response            = client.CreateNotificationChannel(request);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }