示例#1
0
        public async stt::Task ListDebuggeesAsync()
        {
            moq::Mock <Debugger2.Debugger2Client> mockGrpcClient = new moq::Mock <Debugger2.Debugger2Client>(moq::MockBehavior.Strict);
            ListDebuggeesRequest request = new ListDebuggeesRequest
            {
                Project       = "projectaa6ff846",
                ClientVersion = "client_version92be8ead",
            };
            ListDebuggeesResponse expectedResponse = new ListDebuggeesResponse
            {
                Debuggees = { new Debuggee(), },
            };

            mockGrpcClient.Setup(x => x.ListDebuggeesAsync(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(new grpccore::AsyncUnaryCall <ListDebuggeesResponse>(stt::Task.FromResult(expectedResponse), null, null, null, null));
            Debugger2Client       client = new Debugger2ClientImpl(mockGrpcClient.Object, null);
            ListDebuggeesResponse responseCallSettings = await client.ListDebuggeesAsync(request.Project, request.ClientVersion, gaxgrpc::CallSettings.FromCancellationToken(st::CancellationToken.None));

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            ListDebuggeesResponse responseCancellationToken = await client.ListDebuggeesAsync(request.Project, request.ClientVersion, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
        public async Task ListDebuggeesAsync2()
        {
            Mock <Debugger2.Debugger2Client> mockGrpcClient = new Mock <Debugger2.Debugger2Client>(MockBehavior.Strict);
            ListDebuggeesRequest             request        = new ListDebuggeesRequest
            {
                Project       = "project-309310695",
                ClientVersion = "clientVersion-1506231196",
            };
            ListDebuggeesResponse expectedResponse = new ListDebuggeesResponse();

            mockGrpcClient.Setup(x => x.ListDebuggeesAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <ListDebuggeesResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            Debugger2Client       client   = new Debugger2ClientImpl(mockGrpcClient.Object, null);
            ListDebuggeesResponse response = await client.ListDebuggeesAsync(request);

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