Constraint

We found 10 examples in language CSharp for this search. You will see 36 fragments of code.

        [Test]
        public void TestGetters ()
        {
            using (var constraint = FbxConstraintPosition.Create (Manager, "posConstraint")) {
                TestGetter (constraint.AffectX);
                TestGetter (constraint.AffectY);
                TestGetter (constraint.AffectZ);
                TestGetter (constraint.Translation);
            }
        }

        [Test]
        public void TestGetters ()
        {
            using (var constraint = FbxConstraintRotation.Create (Manager, "rConstraint")) {
                TestGetter (constraint.AffectX);
                TestGetter (constraint.AffectY);
                TestGetter (constraint.AffectZ);
                TestGetter (constraint.Rotation);
            }
        }

        [Test]
        public void TestGetters ()
        {
            using (var constraint = FbxConstraintScale.Create (Manager, "sConstraint")) {
                TestGetter (constraint.AffectX);
                TestGetter (constraint.AffectY);
                TestGetter (constraint.AffectZ);
                TestGetter (constraint.Scaling);
            }
        }

            /// <summary>
            /// Constructs a constraint required no other surfaces be included in this shape
            /// </summary>
            /// <returns>Constructed shape constraint</returns>
            public static ShapeConstraint Create_NoOtherSurface()
            {
                ShapeConstraint constraint = new ShapeConstraint();
                constraint.Type = ShapeConstraintType.NoOtherSurface;
                return constraint;
            }

            /// <summary>
            /// Constructs a constraint requiring the shape to be away from all walls
            /// </summary>
            /// <returns>Constructed shape constraint</returns>
            public static ShapeConstraint Create_AwayFromWalls()
            {
                ShapeConstraint constraint = new ShapeConstraint();
                constraint.Type = ShapeConstraintType.AwayFromWalls;
                return constraint;
            }


        [Fact]
        public void ResolveConstraint_RequiredConstraint_ResolvesCorrectly()
        {
            // Arrange & Act
            var constraint = _constraintResolver.ResolveConstraint("required");

            // Assert
            Assert.IsType<RequiredRouteConstraint>(constraint);
        }

        [Fact]
        public void ResolveConstraint_IntConstraint_ResolvesCorrectly()
        {
            // Arrange & Act
            var constraint = _constraintResolver.ResolveConstraint("int");

            // Assert
            Assert.IsType<IntRouteConstraint>(constraint);
        }

        [Fact]
        public void ResolveConstraint_AlphaConstraint()
        {
            // Arrange & Act
            var constraint = _constraintResolver.ResolveConstraint("alpha");

            // Assert
            Assert.IsType<AlphaRouteConstraint>(constraint);
        }

        [Fact]
        public void ResolveConstraint_RegexInlineConstraint_WithAComma_PassesAsASingleArgument()
        {
            // Arrange & Act
            var constraint = _constraintResolver.ResolveConstraint("regex(ab,1)");

            // Assert
            Assert.IsType<RegexInlineRouteConstraint>(constraint);
        }

        [Fact]
        public void ResolveConstraint_RegexInlineConstraint_WithCurlyBraces_Balanced()
        {
            // Arrange & Act
            var constraint = _constraintResolver.ResolveConstraint(
                @"regex(\\b(?<month>\\d{1,2})/(?<day>\\d{1,2})/(?<year>\\d{2,4})\\b)");

            // Assert
            Assert.IsType<RegexInlineRouteConstraint>(constraint);
        }

        [Fact]
        public void ResolveConstraint_BoolConstraint()
        {
            // Arrange & Act
            var constraint = _constraintResolver.ResolveConstraint("bool");

            // Assert
            Assert.IsType<BoolRouteConstraint>(constraint);
        }


        [Test]
        public void TestGetters ()
        {
            using (var constraint = FbxConstraintPosition.Create (Manager, "posConstraint")) {
                TestGetter (constraint.AffectX);
                TestGetter (constraint.AffectY);
                TestGetter (constraint.AffectZ);
                TestGetter (constraint.Translation);
            }
        }

        [Test]
        public void TestGetters ()
        {
            using (var constraint = FbxConstraintRotation.Create (Manager, "rConstraint")) {
                TestGetter (constraint.AffectX);
                TestGetter (constraint.AffectY);
                TestGetter (constraint.AffectZ);
                TestGetter (constraint.Rotation);
            }
        }

        [Test]
        public void TestGetters ()
        {
            using (var constraint = FbxConstraintScale.Create (Manager, "sConstraint")) {
                TestGetter (constraint.AffectX);
                TestGetter (constraint.AffectY);
                TestGetter (constraint.AffectZ);
                TestGetter (constraint.Scaling);
            }
        }


        /// <summary>
        /// Adds the constraint to the collection.
        /// </summary>
        public void Add(Constraint constraint) => Add(constraint, true);

        private void AddForeignKeyConstraint(ForeignKeyConstraint constraint)
        {
            if (!constraint.CanEnableConstraint())
            {
                throw ExceptionBuilder.ConstraintParentValues();
            }
            constraint.CheckCanAddToCollection(this);
        }

        private bool AutoGenerated(Constraint constraint)
        {
            ForeignKeyConstraint fk = (constraint as ForeignKeyConstraint);
            if (null != fk)
            {
                return XmlTreeGen.AutoGenerated(fk, false);
            }
            else
            {
                UniqueConstraint unique = (UniqueConstraint)constraint;
                return XmlTreeGen.AutoGenerated(unique);
            }
        }

        /// <summary>
        ///  Adds the constraint to the constraints array.
        /// </summary>
        private void ArrayAdd(Constraint constraint)
        {
            Debug.Assert(constraint != null, "Attempt to add null constraint to constraint array");
            List.Add(constraint);
        }

        private void ArrayRemove(Constraint constraint)
        {
            List.Remove(constraint);
        }

        /// <summary>
        /// Indicates if a <see cref='System.Data.Constraint'/> can be removed.
        /// </summary>
        // PUBLIC because called by design-time... need to consider this.
        public bool CanRemove(Constraint constraint)
        {
            return CanRemove(constraint, fThrowException: false);
        }

            /// <summary>
            /// Constructs a constraint required no other surfaces be included in this shape
            /// </summary>
            /// <returns>Constructed shape constraint</returns>
            public static ShapeConstraint Create_NoOtherSurface()
            {
                ShapeConstraint constraint = new ShapeConstraint();
                constraint.Type = ShapeConstraintType.NoOtherSurface;
                return constraint;
            }

            /// <summary>
            /// Constructs a constraint requiring the shape to be away from all walls
            /// </summary>
            /// <returns>Constructed shape constraint</returns>
            public static ShapeConstraint Create_AwayFromWalls()
            {
                ShapeConstraint constraint = new ShapeConstraint();
                constraint.Type = ShapeConstraintType.AwayFromWalls;
                return constraint;
            }


        #endregion

        #region Matches

        /// <summary>
        /// Returns the constraint provided as an argument - used to allow custom
        /// custom constraints to easily participate in the syntax.
        /// </summary>
        public Constraint Matches(Constraint constraint)
        {
            return this.Append(constraint);
        }

        #endregion

        #region Constraints with an expected value

        #region Equality and Identity
        /// <summary>
        /// Resolves the chain of constraints using an
        /// EqualConstraint as base.
        /// </summary>
        public Constraint EqualTo(object expected)
        {
            return Resolve(new EqualConstraint(expected));
        }

        /// <summary>
        /// Resolves the chain of constraints using a
        /// SameAsConstraint as base.
        /// </summary>
        public Constraint SameAs(object expected)
        {
            return Resolve(new SameAsConstraint(expected));
        }
        #endregion

        #region Comparison Constraints
        /// <summary>
        /// Resolves the chain of constraints using a
        /// LessThanConstraint as base.
        /// </summary>
        public Constraint LessThan(IComparable expected)
        {
            return Resolve(new LessThanConstraint(expected));
        }

        /// <summary>
        /// Resolves the chain of constraints using a
        /// GreaterThanConstraint as base.
        /// </summary>
        public Constraint GreaterThan(IComparable expected)
        {
            return Resolve(new GreaterThanConstraint(expected));
        }

        /// <summary>
        /// Resolves the chain of constraints using a
        /// LessThanOrEqualConstraint as base.
        /// </summary>
        public Constraint LessThanOrEqualTo(IComparable expected)
        {
            return Resolve(new LessThanOrEqualConstraint(expected));
        }

        /// <summary>
        /// Resolves the chain of constraints using a
        /// LessThanOrEqualConstraint as base.
        /// </summary>
        public Constraint AtMost(IComparable expected)
        {
            return Resolve(new LessThanOrEqualConstraint(expected));
        }


        [Fact]
        public void ParseRouteParameter_WithoutAConstraintName()
        {
            // Arrange & Act
            var templatePart = ParseParameter("param:");

            // Assert
            Assert.Equal("param", templatePart.Name);
            Assert.Null(templatePart.DefaultValue);
            var constraint = Assert.Single(templatePart.InlineConstraints);
            Assert.Empty(constraint.Constraint);
        }

        [Fact]
        public void ParseRouteParameter_WithoutAConstraintNameOrParameterName()
        {
            // Arrange & Act
            var templatePart = ParseParameter("param:=");

            // Assert
            Assert.Equal("param", templatePart.Name);
            Assert.Equal("", templatePart.DefaultValue);
            var constraint = Assert.Single(templatePart.InlineConstraints);
            Assert.Empty(constraint.Constraint);
        }

        [Fact]
        public void ParseRouteParameter_ConstraintAndDefault_ParsedCorrectly()
        {
            // Arrange & Act
            var templatePart = ParseParameter("param:int=111111");

            // Assert
            Assert.Equal("param", templatePart.Name);
            Assert.Equal("111111", templatePart.DefaultValue);

            var constraint = Assert.Single(templatePart.InlineConstraints);
            Assert.Equal("int", constraint.Constraint);
        }

        [Fact]
        public void ParseRouteParameter_ConstraintAndOptional_ParsedCorrectly()
        {
            // Arrange & Act
            var templatePart = ParseParameter(@"param:int?");

            // Assert
            Assert.Equal("param", templatePart.Name);
            Assert.True(templatePart.IsOptional);

            var constraint = Assert.Single(templatePart.InlineConstraints);
            Assert.Equal("int", constraint.Constraint);
        }

        [Fact]
        public void ParseRouteParameter_ConstraintWithArgumentsAndOptional_ParsedCorrectly()
        {
            // Arrange & Act
            var templatePart = ParseParameter(@"param:test(\d+)?");

            // Assert
            Assert.Equal("param", templatePart.Name);
            Assert.True(templatePart.IsOptional);

            var constraint = Assert.Single(templatePart.InlineConstraints);
            Assert.Equal(@"test(\d+)", constraint.Constraint);
        }

        [Fact]
        public void ParseRouteParameter_ConstraintWithClosingBraceInPattern_ClosingBraceIsParsedCorrectly()
        {
            // Arrange & Act
            var templatePart = ParseParameter(@"param:test(\})");

            // Assert
            Assert.Equal("param", templatePart.Name);

            var constraint = Assert.Single(templatePart.InlineConstraints);
            Assert.Equal(@"test(\})", constraint.Constraint);
        }


        private void Add(string key, IRouteConstraint constraint)
        {
            if (!_constraints.TryGetValue(key, out var list))
            {
                list = new List<IRouteConstraint>();
                _constraints.Add(key, list);
            }

            list.Add(constraint);
        }

Google.Apis.CloudResourceManager.v1.Data.Constraint : IDirectResponseSchema

Constructors :

public Constraint()

Methods :

public BooleanConstraint get_BooleanConstraint()
public Void set_BooleanConstraint(BooleanConstraint value = )
public String get_ConstraintDefault()
public Void set_ConstraintDefault(String value = )
public String get_Description()
public Void set_Description(String value = )
public String get_DisplayName()
public Void set_DisplayName(String value = )
public ListConstraint get_ListConstraint()
public Void set_ListConstraint(ListConstraint value = )
public String get_Name()
public Void set_Name(String value = )
public Nullable<Int32> get_Version()
public Void set_Version(Nullable<Int32> value = )
public String get_ETag()
public Void set_ETag(String value = )
public Type GetType()
public String ToString()
public Boolean Equals(Object obj = )
public Int32 GetHashCode()