Пример #1
0
 public async stt::Task GetTopicViewAsync()
 {
     moq::Mock<TopicViewService.TopicViewServiceClient> mockGrpcClient = new moq::Mock<TopicViewService.TopicViewServiceClient>(moq::MockBehavior.Strict);
     GetTopicViewRequest request = new GetTopicViewRequest
     {
         ResourceNameAsTopicViewName = gagvr::TopicViewName.FromCustomerTopicView("[CUSTOMER]", "[TOPIC_VIEW]"),
     };
     gagvr::TopicView expectedResponse = new gagvr::TopicView
     {
         ResourceNameAsTopicViewName = gagvr::TopicViewName.FromCustomerTopicView("[CUSTOMER]", "[TOPIC_VIEW]"),
     };
     mockGrpcClient.Setup(x => x.GetTopicViewAsync(request, moq::It.IsAny<grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall<gagvr::TopicView>(stt::Task.FromResult(expectedResponse), null, null, null, null));
     TopicViewServiceClient client = new TopicViewServiceClientImpl(mockGrpcClient.Object, null);
     gagvr::TopicView responseCallSettings = await client.GetTopicViewAsync(request.ResourceName, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));
     Assert.AreEqual(expectedResponse, responseCallSettings);
     gagvr::TopicView responseCancellationToken = await client.GetTopicViewAsync(request.ResourceName, st::CancellationToken.None);
     Assert.AreEqual(expectedResponse, responseCancellationToken);
     mockGrpcClient.VerifyAll();
 }
Пример #2
0
        public async Task GetTopicViewAsync2()
        {
            Mock <TopicViewService.TopicViewServiceClient> mockGrpcClient = new Mock <TopicViewService.TopicViewServiceClient>(MockBehavior.Strict);
            GetTopicViewRequest request = new GetTopicViewRequest
            {
                ResourceName = new TopicViewName("[CUSTOMER]", "[TOPIC_VIEW]").ToString(),
            };
            TopicView expectedResponse = new TopicView
            {
                ResourceName = "resourceName2625949903",
            };

            mockGrpcClient.Setup(x => x.GetTopicViewAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <TopicView>(Task.FromResult(expectedResponse), null, null, null, null));
            TopicViewServiceClient client = new TopicViewServiceClientImpl(mockGrpcClient.Object, null);
            TopicView response            = await client.GetTopicViewAsync(request);

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