Exemple #1
0
        public async stt::Task TroubleshootIamPolicyRequestObjectAsync()
        {
            moq::Mock <IamChecker.IamCheckerClient> mockGrpcClient = new moq::Mock <IamChecker.IamCheckerClient>(moq::MockBehavior.Strict);
            TroubleshootIamPolicyRequest            request        = new TroubleshootIamPolicyRequest
            {
                AccessTuple = new AccessTuple(),
            };
            TroubleshootIamPolicyResponse expectedResponse = new TroubleshootIamPolicyResponse
            {
                Access            = AccessState.UnknownInfoDenied,
                ExplainedPolicies =
                {
                    new ExplainedPolicy(),
                },
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            TroubleshootIamPolicyResponse responseCancellationToken = await client.TroubleshootIamPolicyAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemple #2
0
        public void TroubleshootIamPolicyRequestObject()
        {
            moq::Mock <IamChecker.IamCheckerClient> mockGrpcClient = new moq::Mock <IamChecker.IamCheckerClient>(moq::MockBehavior.Strict);
            TroubleshootIamPolicyRequest            request        = new TroubleshootIamPolicyRequest
            {
                AccessTuple = new AccessTuple(),
            };
            TroubleshootIamPolicyResponse expectedResponse = new TroubleshootIamPolicyResponse
            {
                Access            = AccessState.UnknownInfoDenied,
                ExplainedPolicies =
                {
                    new ExplainedPolicy(),
                },
            };

            mockGrpcClient.Setup(x => x.TroubleshootIamPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            IamCheckerClient client = new IamCheckerClientImpl(mockGrpcClient.Object, null);
            TroubleshootIamPolicyResponse response = client.TroubleshootIamPolicy(request);

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