Exemplo n.º 1
0
        public async stt::Task GetGcpUserAccessBindingResourceNamesAsync()
        {
            moq::Mock <AccessContextManager.AccessContextManagerClient> mockGrpcClient = new moq::Mock <AccessContextManager.AccessContextManagerClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetGcpUserAccessBindingRequest request = new GetGcpUserAccessBindingRequest
            {
                GcpUserAccessBindingName = GcpUserAccessBindingName.FromOrganizationGcpUserAccessBinding("[ORGANIZATION]", "[GCP_USER_ACCESS_BINDING]"),
            };
            GcpUserAccessBinding expectedResponse = new GcpUserAccessBinding
            {
                GcpUserAccessBindingName = GcpUserAccessBindingName.FromOrganizationGcpUserAccessBinding("[ORGANIZATION]", "[GCP_USER_ACCESS_BINDING]"),
                GroupKey = "group_keycd19b56f",
                AccessLevelsAsAccessLevelNames =
                {
                    AccessLevelName.FromAccessPolicyAccessLevel("[ACCESS_POLICY]", "[ACCESS_LEVEL]"),
                },
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            GcpUserAccessBinding responseCancellationToken = await client.GetGcpUserAccessBindingAsync(request.GcpUserAccessBindingName, st::CancellationToken.None);

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 2
0
        public void GetGcpUserAccessBindingResourceNames()
        {
            moq::Mock <AccessContextManager.AccessContextManagerClient> mockGrpcClient = new moq::Mock <AccessContextManager.AccessContextManagerClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetGcpUserAccessBindingRequest request = new GetGcpUserAccessBindingRequest
            {
                GcpUserAccessBindingName = GcpUserAccessBindingName.FromOrganizationGcpUserAccessBinding("[ORGANIZATION]", "[GCP_USER_ACCESS_BINDING]"),
            };
            GcpUserAccessBinding expectedResponse = new GcpUserAccessBinding
            {
                GcpUserAccessBindingName = GcpUserAccessBindingName.FromOrganizationGcpUserAccessBinding("[ORGANIZATION]", "[GCP_USER_ACCESS_BINDING]"),
                GroupKey = "group_keycd19b56f",
                AccessLevelsAsAccessLevelNames =
                {
                    AccessLevelName.FromAccessPolicyAccessLevel("[ACCESS_POLICY]", "[ACCESS_LEVEL]"),
                },
            };

            mockGrpcClient.Setup(x => x.GetGcpUserAccessBinding(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            AccessContextManagerClient client   = new AccessContextManagerClientImpl(mockGrpcClient.Object, null);
            GcpUserAccessBinding       response = client.GetGcpUserAccessBinding(request.GcpUserAccessBindingName);

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