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

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetAuthorizationPolicyRequest request = new GetAuthorizationPolicyRequest
            {
                AuthorizationPolicyName = AuthorizationPolicyName.FromProjectLocationAuthorizationPolicy("[PROJECT]", "[LOCATION]", "[AUTHORIZATION_POLICY]"),
            };
            AuthorizationPolicy expectedResponse = new AuthorizationPolicy
            {
                AuthorizationPolicyName = AuthorizationPolicyName.FromProjectLocationAuthorizationPolicy("[PROJECT]", "[LOCATION]", "[AUTHORIZATION_POLICY]"),
                Description             = "description2cf9da67",
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                Labels     =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Action = AuthorizationPolicy.Types.Action.Deny,
                Rules  =
                {
                    new AuthorizationPolicy.Types.Rule(),
                },
            };

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

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

            xunit::Assert.Same(expectedResponse, responseCancellationToken);
            mockGrpcClient.VerifyAll();
        }
Exemplo n.º 2
0
        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Key != null?Key.GetHashCode() : 0;

                hashCode = (hashCode * 397) ^ Enabled.GetHashCode();
                hashCode = (hashCode * 397) ^ (Title != null ? Title.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Area != null ? Area.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Controller != null ? Controller.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Action != null ? Action.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (RouteName != null ? RouteName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Url != null ? Url.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Roles != null ? Roles.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^
                           (AuthorizationPolicyName != null ? AuthorizationPolicyName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (int)HideNodeFrom;
                hashCode = (hashCode * 397) ^ (ClassName != null ? ClassName.GetHashCode() : 0);
                hashCode = (hashCode * 397) ^ (Icon != null ? Icon.GetHashCode() : 0);

                return(hashCode);
            }
        }
Exemplo n.º 3
0
        public void GetAuthorizationPolicyRequestObject()
        {
            moq::Mock <NetworkSecurity.NetworkSecurityClient> mockGrpcClient = new moq::Mock <NetworkSecurity.NetworkSecurityClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetAuthorizationPolicyRequest request = new GetAuthorizationPolicyRequest
            {
                AuthorizationPolicyName = AuthorizationPolicyName.FromProjectLocationAuthorizationPolicy("[PROJECT]", "[LOCATION]", "[AUTHORIZATION_POLICY]"),
            };
            AuthorizationPolicy expectedResponse = new AuthorizationPolicy
            {
                AuthorizationPolicyName = AuthorizationPolicyName.FromProjectLocationAuthorizationPolicy("[PROJECT]", "[LOCATION]", "[AUTHORIZATION_POLICY]"),
                Description             = "description2cf9da67",
                CreateTime = new wkt::Timestamp(),
                UpdateTime = new wkt::Timestamp(),
                Labels     =
                {
                    {
                        "key8a0b6e3c",
                        "value60c16320"
                    },
                },
                Action = AuthorizationPolicy.Types.Action.Deny,
                Rules  =
                {
                    new AuthorizationPolicy.Types.Rule(),
                },
            };

            mockGrpcClient.Setup(x => x.GetAuthorizationPolicy(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            NetworkSecurityClient client   = new NetworkSecurityClientImpl(mockGrpcClient.Object, null);
            AuthorizationPolicy   response = client.GetAuthorizationPolicy(request);

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