예제 #1
0
        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();
        }
        public void VerifyNotificationChannel2()
        {
            Mock <NotificationChannelService.NotificationChannelServiceClient> mockGrpcClient = new Mock <NotificationChannelService.NotificationChannelServiceClient>(MockBehavior.Strict);
            VerifyNotificationChannelRequest request = new VerifyNotificationChannelRequest
            {
                NotificationChannelName = new NotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]"),
                Code = "code3059181",
            };
            NotificationChannel expectedResponse = new NotificationChannel
            {
                Type        = "type3575610",
                Name        = "name2-1052831874",
                DisplayName = "displayName1615086568",
                Description = "description-1724546052",
            };

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

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
예제 #3
0
        public async Task GetNotificationChannelAsync()
        {
            Mock <NotificationChannelService.NotificationChannelServiceClient> mockGrpcClient = new Mock <NotificationChannelService.NotificationChannelServiceClient>(MockBehavior.Strict);
            GetNotificationChannelRequest expectedRequest = new GetNotificationChannelRequest
            {
                NotificationChannelName = new NotificationChannelName("[PROJECT]", "[NOTIFICATION_CHANNEL]"),
            };
            NotificationChannel expectedResponse = new NotificationChannel
            {
                Type        = "type3575610",
                Name        = "name2-1052831874",
                DisplayName = "displayName1615086568",
                Description = "description-1724546052",
            };

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

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public void GetNotificationChannelDescriptor()
        {
            Mock <NotificationChannelService.NotificationChannelServiceClient> mockGrpcClient = new Mock <NotificationChannelService.NotificationChannelServiceClient>(MockBehavior.Strict);
            GetNotificationChannelDescriptorRequest expectedRequest = new GetNotificationChannelDescriptorRequest
            {
                NotificationChannelDescriptorName = new NotificationChannelDescriptorName("[PROJECT]", "[CHANNEL_DESCRIPTOR]"),
            };
            NotificationChannelDescriptor expectedResponse = new NotificationChannelDescriptor
            {
                Name        = "name2-1052831874",
                Type        = "type3575610",
                DisplayName = "displayName1615086568",
                Description = "description-1724546052",
            };

            mockGrpcClient.Setup(x => x.GetNotificationChannelDescriptor(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            NotificationChannelServiceClient  client   = new NotificationChannelServiceClientImpl(mockGrpcClient.Object, null);
            NotificationChannelDescriptorName name     = new NotificationChannelDescriptorName("[PROJECT]", "[CHANNEL_DESCRIPTOR]");
            NotificationChannelDescriptor     response = client.GetNotificationChannelDescriptor(name);

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