Пример #1
0
        public async stt::Task GetTopicConstantRequestObjectAsync()
        {
            moq::Mock <TopicConstantService.TopicConstantServiceClient> mockGrpcClient = new moq::Mock <TopicConstantService.TopicConstantServiceClient>(moq::MockBehavior.Strict);
            GetTopicConstantRequest request = new GetTopicConstantRequest
            {
                ResourceNameAsTopicConstantName = gagvr::TopicConstantName.FromTopic("[TOPIC_ID]"),
            };
            gagvr::TopicConstant expectedResponse = new gagvr::TopicConstant
            {
                ResourceNameAsTopicConstantName = gagvr::TopicConstantName.FromTopic("[TOPIC_ID]"),
                Id = -6774108720365892680L,
                TopicConstantParentAsTopicConstantName = gagvr::TopicConstantName.FromTopic("[TOPIC_ID]"),
                Path = { "path0b1dfed6", },
            };

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

            Assert.AreEqual(expectedResponse, responseCallSettings);
            gagvr::TopicConstant responseCancellationToken = await client.GetTopicConstantAsync(request, st::CancellationToken.None);

            Assert.AreEqual(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Пример #2
0
        public void GetTopicConstant2()
        {
            Mock <TopicConstantService.TopicConstantServiceClient> mockGrpcClient = new Mock <TopicConstantService.TopicConstantServiceClient>(MockBehavior.Strict);
            GetTopicConstantRequest request = new GetTopicConstantRequest
            {
                ResourceName = new TopicConstantName("[TOPIC_CONSTANT]").ToString(),
            };
            TopicConstant expectedResponse = new TopicConstant
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetTopicConstant(request, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            TopicConstantServiceClient client = new TopicConstantServiceClientImpl(mockGrpcClient.Object, null);
            TopicConstant response            = client.GetTopicConstant(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Пример #3
0
        public async Task GetTopicConstantAsync2()
        {
            Mock <TopicConstantService.TopicConstantServiceClient> mockGrpcClient = new Mock <TopicConstantService.TopicConstantServiceClient>(MockBehavior.Strict);
            GetTopicConstantRequest request = new GetTopicConstantRequest
            {
                ResourceName = new TopicConstantName("[TOPIC_CONSTANT]").ToString(),
            };
            TopicConstant expectedResponse = new TopicConstant
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetTopicConstantAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <TopicConstant>(Task.FromResult(expectedResponse), null, null, null, null));
            TopicConstantServiceClient client = new TopicConstantServiceClientImpl(mockGrpcClient.Object, null);
            TopicConstant response            = await client.GetTopicConstantAsync(request);

            Assert.AreEqual(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
Пример #4
0
        public void GetTopicConstant()
        {
            moq::Mock <TopicConstantService.TopicConstantServiceClient> mockGrpcClient = new moq::Mock <TopicConstantService.TopicConstantServiceClient>(moq::MockBehavior.Strict);
            GetTopicConstantRequest request = new GetTopicConstantRequest
            {
                ResourceNameAsTopicConstantName = gagvr::TopicConstantName.FromTopic("[TOPIC_ID]"),
            };
            gagvr::TopicConstant expectedResponse = new gagvr::TopicConstant
            {
                ResourceNameAsTopicConstantName = gagvr::TopicConstantName.FromTopic("[TOPIC_ID]"),
                Id = -6774108720365892680L,
                TopicConstantParentAsTopicConstantName = gagvr::TopicConstantName.FromTopic("[TOPIC_ID]"),
                Path = { "path0b1dfed6", },
            };

            mockGrpcClient.Setup(x => x.GetTopicConstant(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            TopicConstantServiceClient client   = new TopicConstantServiceClientImpl(mockGrpcClient.Object, null);
            gagvr::TopicConstant       response = client.GetTopicConstant(request.ResourceName);

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