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(); }
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(); }