PageRenderTime 14ms CodeModel.GetById 9ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 1ms

/src/NUnit/framework/Constraints/ResolvableConstraintExpression.cs

#
C# | 62 lines | 24 code | 6 blank | 32 comment | 0 complexity | 10f4900f595a78b298afb39b6705e86f MD5 | raw file
 1// ****************************************************************
 2// Copyright 2008, Charlie Poole
 3// This is free software licensed under the NUnit license. You may
 4// obtain a copy of the license at http://nunit.org
 5// ****************************************************************
 6
 7using System;
 8
 9namespace NUnit.Framework.Constraints
10{
11    /// <summary>
12    /// ResolvableConstraintExpression is used to represent a compound
13    /// constraint being constructed at a point where the last operator
14    /// may either terminate the expression or may have additional 
15    /// qualifying constraints added to it. 
16    /// 
17    /// It is used, for example, for a Property element or for
18    /// an Exception element, either of which may be optionally
19    /// followed by constraints that apply to the property or 
20    /// exception.
21    /// </summary>
22    public class ResolvableConstraintExpression : ConstraintExpression, IResolveConstraint
23    {
24        /// <summary>
25        /// Create a new instance of ResolvableConstraintExpression
26        /// </summary>
27        public ResolvableConstraintExpression() { }
28
29        /// <summary>
30        /// Create a new instance of ResolvableConstraintExpression,
31        /// passing in a pre-populated ConstraintBuilder.
32        /// </summary>
33        public ResolvableConstraintExpression(ConstraintBuilder builder)
34            : base(builder) { }
35
36        /// <summary>
37        /// Appends an And Operator to the expression
38        /// </summary>
39        public ConstraintExpression And
40        {
41            get { return this.Append(new AndOperator()); }
42        }
43
44        /// <summary>
45        /// Appends an Or operator to the expression.
46        /// </summary>
47        public ConstraintExpression Or
48        {
49            get { return this.Append(new OrOperator()); }
50        }
51
52        #region IResolveConstraint Members
53        /// <summary>
54        /// Resolve the current expression to a Constraint
55        /// </summary>
56        Constraint IResolveConstraint.Resolve()
57        {
58            return builder.Resolve();
59        }
60        #endregion
61    }
62}