public async stt::Task SetIamPolicyRequestObjectAsync()
        {
            moq::Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new moq::Mock <ContainerAnalysis.ContainerAnalysisClient>(moq::MockBehavior.Strict);
            gciv::SetIamPolicyRequest request = new gciv::SetIamPolicyRequest
            {
                ResourceAsResourceName = new gax::UnparsedResourceName("a/wildcard/resource"),
                Policy = new gciv::Policy(),
            };
            gciv::Policy expectedResponse = new gciv::Policy
            {
                Version  = 271578922,
                Etag     = proto::ByteString.CopyFromUtf8("etage8ad7218"),
                Bindings =
                {
                    new gciv::Binding(),
                },
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            gciv::Policy responseCancellationToken = await client.SetIamPolicyAsync(request, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Beispiel #2
0
        public async Task SetIamPolicyAsync2()
        {
            Mock <ContainerAnalysis.ContainerAnalysisClient> mockGrpcClient = new Mock <ContainerAnalysis.ContainerAnalysisClient>(MockBehavior.Strict);
            SetIamPolicyRequest request = new SetIamPolicyRequest
            {
                ResourceAsResourceName = IamResourceNameOneof.From(new NoteName("[PROJECT]", "[NOTE]")),
                Policy = new Policy(),
            };
            Policy expectedResponse = new Policy
            {
                Version = 351608024,
                Etag    = ByteString.CopyFromUtf8("21"),
            };

            mockGrpcClient.Setup(x => x.SetIamPolicyAsync(request, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <Policy>(Task.FromResult(expectedResponse), null, null, null, null));
            ContainerAnalysisClient client = new ContainerAnalysisClientImpl(mockGrpcClient.Object, null);
            Policy response = await client.SetIamPolicyAsync(request);

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