Ejemplo n.º 1
0
        public void GetOSPolicyAssignmentRequestObject()
        {
            moq::Mock <OsConfigZonalService.OsConfigZonalServiceClient> mockGrpcClient = new moq::Mock <OsConfigZonalService.OsConfigZonalServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetOSPolicyAssignmentRequest request = new GetOSPolicyAssignmentRequest
            {
                OSPolicyAssignmentName = OSPolicyAssignmentName.FromProjectLocationOsPolicyAssignment("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"),
            };
            OSPolicyAssignment expectedResponse = new OSPolicyAssignment
            {
                OSPolicyAssignmentName = OSPolicyAssignmentName.FromProjectLocationOsPolicyAssignment("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"),
                Description            = "description2cf9da67",
                OsPolicies             = { new OSPolicy(), },
                InstanceFilter         = new OSPolicyAssignment.Types.InstanceFilter(),
                Rollout            = new OSPolicyAssignment.Types.Rollout(),
                RevisionId         = "revision_id8d9ae05d",
                RevisionCreateTime = new wkt::Timestamp(),
                Etag         = "etage8ad7218",
                RolloutState = OSPolicyAssignment.Types.RolloutState.Cancelling,
                Baseline     = false,
                Deleted      = true,
                Reconciling  = false,
                Uid          = "uida2d37198",
            };

            mockGrpcClient.Setup(x => x.GetOSPolicyAssignment(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse);
            OsConfigZonalServiceClient client   = new OsConfigZonalServiceClientImpl(mockGrpcClient.Object, null);
            OSPolicyAssignment         response = client.GetOSPolicyAssignment(request);

            xunit::Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
        public async stt::Task GetOSPolicyAssignmentResourceNamesAsync()
        {
            moq::Mock <OsConfigZonalService.OsConfigZonalServiceClient> mockGrpcClient = new moq::Mock <OsConfigZonalService.OsConfigZonalServiceClient>(moq::MockBehavior.Strict);

            mockGrpcClient.Setup(x => x.CreateOperationsClient()).Returns(new moq::Mock <lro::Operations.OperationsClient>().Object);
            GetOSPolicyAssignmentRequest request = new GetOSPolicyAssignmentRequest
            {
                OSPolicyAssignmentName = OSPolicyAssignmentName.FromProjectLocationOsPolicyAssignment("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"),
            };
            OSPolicyAssignment expectedResponse = new OSPolicyAssignment
            {
                OSPolicyAssignmentName = OSPolicyAssignmentName.FromProjectLocationOsPolicyAssignment("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"),
                Description            = "description2cf9da67",
                OsPolicies             = { new OSPolicy(), },
                InstanceFilter         = new OSPolicyAssignment.Types.InstanceFilter(),
                Rollout            = new OSPolicyAssignment.Types.Rollout(),
                RevisionId         = "revision_id8d9ae05d",
                RevisionCreateTime = new wkt::Timestamp(),
                RolloutState       = OSPolicyAssignment.Types.RolloutState.Cancelling,
                Baseline           = false,
                Deleted            = true,
                Reconciling        = false,
                Uid = "uida2d37198",
            };

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

            xunit::Assert.Same(expectedResponse, responseCallSettings);
            OSPolicyAssignment responseCancellationToken = await client.GetOSPolicyAssignmentAsync(request.OSPolicyAssignmentName, st::CancellationToken.None);

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