[NUI] Rebase develnui (DevelNUI only patches --> master) (#3910)
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Devel.Tests.Ubuntu / nunit.framework / Constraints / ConstraintExpression.cs
1 // ***********************************************************************
2 // Copyright (c) 2009 Charlie Poole
3 //
4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
11 // 
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 // 
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 // ***********************************************************************
23 #define PORTABLE
24 #define TIZEN
25 #define NUNIT_FRAMEWORK
26 #define NUNITLITE
27 #define NET_4_5
28 #define PARALLEL
29 using System;
30 using System.Collections;
31 using System.Runtime.CompilerServices;
32
33 namespace NUnit.Framework.Constraints
34 {
35     /// <summary>
36     /// ConstraintExpression represents a compound constraint in the 
37     /// process of being constructed from a series of syntactic elements.
38     /// 
39     /// Individual elements are appended to the expression as they are
40     /// reorganized. When a constraint is appended, it is returned as the
41     /// value of the operation so that modifiers may be applied. However,
42     /// any partially built expression is attached to the constraint for
43     /// later resolution. When an operator is appended, the partial
44     /// expression is returned. If it's a self-resolving operator, then
45     /// a ResolvableConstraintExpression is returned.
46     /// </summary>
47     public class ConstraintExpression
48     {
49         #region Instance Fields
50
51         /// <summary>
52         /// The ConstraintBuilder holding the elements recognized so far
53         /// </summary>
54         protected ConstraintBuilder builder;
55
56         #endregion
57
58         #region Constructors
59
60         /// <summary>
61         /// Initializes a new instance of the <see cref="ConstraintExpression"/> class.
62         /// </summary>
63         public ConstraintExpression() 
64         {
65             this.builder = new ConstraintBuilder();
66         }
67
68         /// <summary>
69         /// Initializes a new instance of the <see cref="ConstraintExpression"/> 
70         /// class passing in a ConstraintBuilder, which may be pre-populated.
71         /// </summary>
72         /// <param name="builder">The builder.</param>
73         public ConstraintExpression(ConstraintBuilder builder)
74         {
75             this.builder = builder;
76         }
77
78         #endregion
79
80         #region ToString()
81
82         /// <summary>
83         /// Returns a string representation of the expression as it
84         /// currently stands. This should only be used for testing,
85         /// since it has the side-effect of resolving the expression.
86         /// </summary>
87         /// <returns></returns>
88         public override string ToString()
89         {
90             return builder.Resolve().ToString();
91         }
92
93         #endregion
94
95         #region Append Methods
96
97         /// <summary>
98         /// Appends an operator to the expression and returns the
99         /// resulting expression itself.
100         /// </summary>
101         public ConstraintExpression Append(ConstraintOperator op)
102         {
103             builder.Append(op);
104             return this;
105         }
106
107         /// <summary>
108         /// Appends a self-resolving operator to the expression and
109         /// returns a new ResolvableConstraintExpression.
110         /// </summary>
111         public ResolvableConstraintExpression Append(SelfResolvingOperator op)
112         {
113             builder.Append(op);
114             return new ResolvableConstraintExpression(builder);
115         }
116
117         /// <summary>
118         /// Appends a constraint to the expression and returns that
119         /// constraint, which is associated with the current state
120         /// of the expression being built. Note that the constraint
121         /// is not reduced at this time. For example, if there 
122         /// is a NotOperator on the stack we don't reduce and
123         /// return a NotConstraint. The original constraint must
124         /// be returned because it may support modifiers that
125         /// are yet to be applied.
126         /// </summary>
127         public Constraint Append(Constraint constraint)
128         {
129             builder.Append(constraint);
130             return constraint;
131         }
132
133         #endregion
134
135         #region Not
136
137         /// <summary>
138         /// Returns a ConstraintExpression that negates any
139         /// following constraint.
140         /// </summary>
141         public ConstraintExpression Not
142         {
143             get { return this.Append(new NotOperator()); }
144         }
145
146         /// <summary>
147         /// Returns a ConstraintExpression that negates any
148         /// following constraint.
149         /// </summary>
150         public ConstraintExpression No
151         {
152             get { return this.Append(new NotOperator()); }
153         }
154
155         #endregion
156
157         #region All
158
159         /// <summary>
160         /// Returns a ConstraintExpression, which will apply
161         /// the following constraint to all members of a collection,
162         /// succeeding if all of them succeed.
163         /// </summary>
164         public ConstraintExpression All
165         {
166             get { return this.Append(new AllOperator()); }
167         }
168
169         #endregion
170
171         #region Some
172
173         /// <summary>
174         /// Returns a ConstraintExpression, which will apply
175         /// the following constraint to all members of a collection,
176         /// succeeding if at least one of them succeeds.
177         /// </summary>
178         public ConstraintExpression Some
179         {
180             get { return this.Append(new SomeOperator()); }
181         }
182
183         #endregion
184
185         #region None
186
187         /// <summary>
188         /// Returns a ConstraintExpression, which will apply
189         /// the following constraint to all members of a collection,
190         /// succeeding if all of them fail.
191         /// </summary>
192         public ConstraintExpression None
193         {
194             get { return this.Append(new NoneOperator()); }
195         }
196
197         #endregion
198         
199         #region Exactly(n)
200         
201         /// <summary>
202         /// Returns a ConstraintExpression, which will apply
203         /// the following constraint to all members of a collection,
204         /// succeeding only if a specified number of them succeed.
205         /// </summary>
206         public ConstraintExpression Exactly(int expectedCount)
207         {
208             return this.Append(new ExactCountOperator(expectedCount));
209         }
210         
211         #endregion
212         
213         #region Property
214
215         /// <summary>
216         /// Returns a new PropertyConstraintExpression, which will either
217         /// test for the existence of the named property on the object
218         /// being tested or apply any following constraint to that property.
219         /// </summary>
220         public ResolvableConstraintExpression Property(string name)
221         {
222             return this.Append(new PropOperator(name));
223         }
224
225         #endregion
226
227         #region Length
228
229         /// <summary>
230         /// Returns a new ConstraintExpression, which will apply the following
231         /// constraint to the Length property of the object being tested.
232         /// </summary>
233         public ResolvableConstraintExpression Length
234         {
235             get { return Property("Length"); }
236         }
237
238         #endregion
239
240         #region Count
241
242         /// <summary>
243         /// Returns a new ConstraintExpression, which will apply the following
244         /// constraint to the Count property of the object being tested.
245         /// </summary>
246         public ResolvableConstraintExpression Count
247         {
248             get { return Property("Count"); }
249         }
250
251         #endregion
252
253         #region Message
254
255         /// <summary>
256         /// Returns a new ConstraintExpression, which will apply the following
257         /// constraint to the Message property of the object being tested.
258         /// </summary>
259         public ResolvableConstraintExpression Message
260         {
261             get { return Property("Message"); }
262         }
263
264         #endregion
265
266         #region InnerException
267
268         /// <summary>
269         /// Returns a new ConstraintExpression, which will apply the following
270         /// constraint to the InnerException property of the object being tested.
271         /// </summary>
272         public ResolvableConstraintExpression InnerException
273         {
274             get { return Property("InnerException"); }
275         }
276
277         #endregion
278         
279         #region Attribute
280
281         /// <summary>
282         /// Returns a new AttributeConstraint checking for the
283         /// presence of a particular attribute on an object.
284         /// </summary>
285         public ResolvableConstraintExpression Attribute(Type expectedType)
286         {
287             return this.Append(new AttributeOperator(expectedType));
288         }
289
290         /// <summary>
291         /// Returns a new AttributeConstraint checking for the
292         /// presence of a particular attribute on an object.
293         /// </summary>
294         public ResolvableConstraintExpression Attribute<TExpected>()
295         {
296             return Attribute(typeof(TExpected));
297         }
298
299         #endregion
300
301         #region With
302
303         /// <summary>
304         /// With is currently a NOP - reserved for future use.
305         /// </summary>
306         public ConstraintExpression With
307         {
308             get { return this.Append(new WithOperator()); }
309         }
310
311         #endregion
312
313         #region Matches
314
315         /// <summary>
316         /// Returns the constraint provided as an argument - used to allow custom
317         /// custom constraints to easily participate in the syntax.
318         /// </summary>
319         public Constraint Matches(IResolveConstraint constraint)
320         {
321             return this.Append((Constraint)constraint.Resolve());
322         }
323
324         /// <summary>
325         /// Returns the constraint provided as an argument - used to allow custom
326         /// custom constraints to easily participate in the syntax.
327         /// </summary>
328         public Constraint Matches<TActual>(Predicate<TActual> predicate)
329         {
330             return this.Append(new PredicateConstraint<TActual>(predicate));
331         }
332
333         #endregion
334
335         #region Null
336
337         /// <summary>
338         /// Returns a constraint that tests for null
339         /// </summary>
340         public NullConstraint Null
341         {
342             get { return (NullConstraint)this.Append(new NullConstraint()); }
343         }
344
345         #endregion
346
347         #region True
348
349         /// <summary>
350         /// Returns a constraint that tests for True
351         /// </summary>
352         public TrueConstraint True
353         {
354             get { return (TrueConstraint)this.Append(new TrueConstraint()); }
355         }
356
357         #endregion
358
359         #region False
360
361         /// <summary>
362         /// Returns a constraint that tests for False
363         /// </summary>
364         public FalseConstraint False
365         {
366             get { return (FalseConstraint)this.Append(new FalseConstraint()); }
367         }
368
369         #endregion
370
371         #region Positive
372  
373         /// <summary>
374         /// Returns a constraint that tests for a positive value
375         /// </summary>
376         public GreaterThanConstraint Positive
377         {
378             get { return (GreaterThanConstraint)this.Append(new GreaterThanConstraint(0)); }
379         }
380  
381         #endregion
382  
383         #region Negative
384  
385         /// <summary>
386         /// Returns a constraint that tests for a negative value
387         /// </summary>
388         public LessThanConstraint Negative
389         {
390             get { return (LessThanConstraint)this.Append(new LessThanConstraint(0)); }
391         }
392
393         #endregion
394
395         #region Zero
396
397         /// <summary>
398         /// Returns a constraint that tests if item is equal to zero
399         /// </summary>
400         public EqualConstraint Zero
401         {
402             get { return (EqualConstraint)this.Append(new EqualConstraint(0)); }
403         }
404
405         #endregion
406
407         #region NaN
408
409         /// <summary>
410         /// Returns a constraint that tests for NaN
411         /// </summary>
412         public NaNConstraint NaN
413         {
414             get { return (NaNConstraint)this.Append(new NaNConstraint()); }
415         }
416
417         #endregion
418
419         #region Empty
420
421         /// <summary>
422         /// Returns a constraint that tests for empty
423         /// </summary>
424         public EmptyConstraint Empty
425         {
426             get { return (EmptyConstraint)this.Append(new EmptyConstraint()); }
427         }
428
429         #endregion
430
431         #region Unique
432
433         /// <summary>
434         /// Returns a constraint that tests whether a collection 
435         /// contains all unique items.
436         /// </summary>
437         public UniqueItemsConstraint Unique
438         {
439             get { return (UniqueItemsConstraint)this.Append(new UniqueItemsConstraint()); }
440         }
441
442         #endregion
443
444         #region BinarySerializable
445
446 #if !NETCF && !SILVERLIGHT && !PORTABLE
447         /// <summary>
448         /// Returns a constraint that tests whether an object graph is serializable in binary format.
449         /// </summary>
450         public BinarySerializableConstraint BinarySerializable
451         {
452             get { return (BinarySerializableConstraint)this.Append(new BinarySerializableConstraint()); }
453         }
454 #endif
455
456         #endregion
457
458         #region XmlSerializable
459
460 #if !SILVERLIGHT && !PORTABLE
461         /// <summary>
462         /// Returns a constraint that tests whether an object graph is serializable in xml format.
463         /// </summary>
464         public XmlSerializableConstraint XmlSerializable
465         {
466             get { return (XmlSerializableConstraint)this.Append(new XmlSerializableConstraint()); }
467         }
468 #endif
469
470         #endregion
471
472         #region EqualTo
473
474         /// <summary>
475         /// Returns a constraint that tests two items for equality
476         /// </summary>
477         public EqualConstraint EqualTo(object expected)
478         {
479             return (EqualConstraint)this.Append(new EqualConstraint(expected));
480         }
481
482         #endregion
483
484         #region SameAs
485
486         /// <summary>
487         /// Returns a constraint that tests that two references are the same object
488         /// </summary>
489         public SameAsConstraint SameAs(object expected)
490         {
491             return (SameAsConstraint)this.Append(new SameAsConstraint(expected));
492         }
493
494         #endregion
495
496         #region GreaterThan
497
498         /// <summary>
499         /// Returns a constraint that tests whether the
500         /// actual value is greater than the supplied argument
501         /// </summary>
502         public GreaterThanConstraint GreaterThan(object expected)
503         {
504             return (GreaterThanConstraint)this.Append(new GreaterThanConstraint(expected));
505         }
506
507         #endregion
508
509         #region GreaterThanOrEqualTo
510
511         /// <summary>
512         /// Returns a constraint that tests whether the
513         /// actual value is greater than or equal to the supplied argument
514         /// </summary>
515         public GreaterThanOrEqualConstraint GreaterThanOrEqualTo(object expected)
516         {
517             return (GreaterThanOrEqualConstraint)this.Append(new GreaterThanOrEqualConstraint(expected));
518         }
519
520         /// <summary>
521         /// Returns a constraint that tests whether the
522         /// actual value is greater than or equal to the supplied argument
523         /// </summary>
524         public GreaterThanOrEqualConstraint AtLeast(object expected)
525         {
526             return (GreaterThanOrEqualConstraint)this.Append(new GreaterThanOrEqualConstraint(expected));
527         }
528
529         #endregion
530
531         #region LessThan
532
533         /// <summary>
534         /// Returns a constraint that tests whether the
535         /// actual value is less than the supplied argument
536         /// </summary>
537         public LessThanConstraint LessThan(object expected)
538         {
539             return (LessThanConstraint)this.Append(new LessThanConstraint(expected));
540         }
541
542         #endregion
543
544         #region LessThanOrEqualTo
545
546         /// <summary>
547         /// Returns a constraint that tests whether the
548         /// actual value is less than or equal to the supplied argument
549         /// </summary>
550         public LessThanOrEqualConstraint LessThanOrEqualTo(object expected)
551         {
552             return (LessThanOrEqualConstraint)this.Append(new LessThanOrEqualConstraint(expected));
553         }
554
555         /// <summary>
556         /// Returns a constraint that tests whether the
557         /// actual value is less than or equal to the supplied argument
558         /// </summary>
559         public LessThanOrEqualConstraint AtMost(object expected)
560         {
561             return (LessThanOrEqualConstraint)this.Append(new LessThanOrEqualConstraint(expected));
562         }
563
564         #endregion
565
566         #region TypeOf
567
568         /// <summary>
569         /// Returns a constraint that tests whether the actual
570         /// value is of the exact type supplied as an argument.
571         /// </summary>
572         public ExactTypeConstraint TypeOf(Type expectedType)
573         {
574             return (ExactTypeConstraint)this.Append(new ExactTypeConstraint(expectedType));
575         }
576
577         /// <summary>
578         /// Returns a constraint that tests whether the actual
579         /// value is of the exact type supplied as an argument.
580         /// </summary>
581         public ExactTypeConstraint TypeOf<TExpected>()
582         {
583             return (ExactTypeConstraint)this.Append(new ExactTypeConstraint(typeof(TExpected)));
584         }
585
586         #endregion
587
588         #region InstanceOf
589
590         /// <summary>
591         /// Returns a constraint that tests whether the actual value
592         /// is of the type supplied as an argument or a derived type.
593         /// </summary>
594         public InstanceOfTypeConstraint InstanceOf(Type expectedType)
595         {
596             return (InstanceOfTypeConstraint)this.Append(new InstanceOfTypeConstraint(expectedType));
597         }
598
599         /// <summary>
600         /// Returns a constraint that tests whether the actual value
601         /// is of the type supplied as an argument or a derived type.
602         /// </summary>
603         public InstanceOfTypeConstraint InstanceOf<TExpected>()
604         {
605             return (InstanceOfTypeConstraint)this.Append(new InstanceOfTypeConstraint(typeof(TExpected)));
606         }
607
608         #endregion
609
610         #region AssignableFrom
611
612         /// <summary>
613         /// Returns a constraint that tests whether the actual value
614         /// is assignable from the type supplied as an argument.
615         /// </summary>
616         public AssignableFromConstraint AssignableFrom(Type expectedType)
617         {
618             return (AssignableFromConstraint)this.Append(new AssignableFromConstraint(expectedType));
619         }
620
621         /// <summary>
622         /// Returns a constraint that tests whether the actual value
623         /// is assignable from the type supplied as an argument.
624         /// </summary>
625         public AssignableFromConstraint AssignableFrom<TExpected>()
626         {
627             return (AssignableFromConstraint)this.Append(new AssignableFromConstraint(typeof(TExpected)));
628         }
629
630         #endregion
631
632         #region AssignableTo
633
634         /// <summary>
635         /// Returns a constraint that tests whether the actual value
636         /// is assignable from the type supplied as an argument.
637         /// </summary>
638         public AssignableToConstraint AssignableTo(Type expectedType)
639         {
640             return (AssignableToConstraint)this.Append(new AssignableToConstraint(expectedType));
641         }
642
643         /// <summary>
644         /// Returns a constraint that tests whether the actual value
645         /// is assignable from the type supplied as an argument.
646         /// </summary>
647         public AssignableToConstraint AssignableTo<TExpected>()
648         {
649             return (AssignableToConstraint)this.Append(new AssignableToConstraint(typeof(TExpected)));
650         }
651
652         #endregion
653
654         #region EquivalentTo
655
656         /// <summary>
657         /// Returns a constraint that tests whether the actual value
658         /// is a collection containing the same elements as the 
659         /// collection supplied as an argument.
660         /// </summary>
661         public CollectionEquivalentConstraint EquivalentTo(IEnumerable expected)
662         {
663             return (CollectionEquivalentConstraint)this.Append(new CollectionEquivalentConstraint(expected));
664         }
665
666         #endregion
667
668         #region SubsetOf
669
670         /// <summary>
671         /// Returns a constraint that tests whether the actual value
672         /// is a subset of the collection supplied as an argument.
673         /// </summary>
674         public CollectionSubsetConstraint SubsetOf(IEnumerable expected)
675         {
676             return (CollectionSubsetConstraint)this.Append(new CollectionSubsetConstraint(expected));
677         }
678
679         #endregion
680
681         #region SupersetOf
682
683         /// <summary>
684         /// Returns a constraint that tests whether the actual value
685         /// is a superset of the collection supplied as an argument.
686         /// </summary>
687         public CollectionSupersetConstraint SupersetOf(IEnumerable expected)
688         {
689             return (CollectionSupersetConstraint)this.Append(new CollectionSupersetConstraint(expected));
690         }
691
692         #endregion
693
694         #region Ordered
695
696         /// <summary>
697         /// Returns a constraint that tests whether a collection is ordered
698         /// </summary>
699         public CollectionOrderedConstraint Ordered
700         {
701             get { return (CollectionOrderedConstraint)this.Append(new CollectionOrderedConstraint()); }
702         }
703
704         #endregion
705
706         #region Member
707
708         /// <summary>
709         /// Returns a new CollectionContainsConstraint checking for the
710         /// presence of a particular object in the collection.
711         /// </summary>
712         public CollectionContainsConstraint Member(object expected)
713         {
714             return (CollectionContainsConstraint)this.Append(new CollectionContainsConstraint(expected));
715         }
716
717         #endregion
718
719         #region Contains
720
721         /// <summary>
722         /// Returns a new CollectionContainsConstraint checking for the
723         /// presence of a particular object in the collection.
724         /// </summary>
725         public CollectionContainsConstraint Contains(object expected)
726         {
727             return (CollectionContainsConstraint)this.Append(new CollectionContainsConstraint(expected));
728         }
729
730         /// <summary>
731         /// Returns a new ContainsConstraint. This constraint
732         /// will, in turn, make use of the appropriate second-level
733         /// constraint, depending on the type of the actual argument. 
734         /// This overload is only used if the item sought is a string,
735         /// since any other type implies that we are looking for a 
736         /// collection member.
737         /// </summary>
738         public ContainsConstraint Contains(string expected)
739         {
740             return (ContainsConstraint)this.Append(new ContainsConstraint(expected));
741         }
742
743         /// <summary>
744         /// Returns a new ContainsConstraint. This constraint
745         /// will, in turn, make use of the appropriate second-level
746         /// constraint, depending on the type of the actual argument. 
747         /// This overload is only used if the item sought is a string,
748         /// since any other type implies that we are looking for a 
749         /// collection member.
750         /// </summary>
751         public ContainsConstraint Contain(string expected)
752         {
753             return (ContainsConstraint)this.Append(new ContainsConstraint(expected));
754         }
755
756         #endregion
757
758         #region StringContaining
759
760         /// <summary>
761         /// Returns a constraint that succeeds if the actual
762         /// value contains the substring supplied as an argument.
763         /// </summary>
764         [Obsolete("Deprecated, use Contains")]
765         public SubstringConstraint StringContaining(string expected)
766         {
767             return (SubstringConstraint)this.Append(new SubstringConstraint(expected));
768         }
769
770         /// <summary>
771         /// Returns a constraint that succeeds if the actual
772         /// value contains the substring supplied as an argument.
773         /// </summary>
774         [Obsolete("Deprecated, use Contains")]
775         public SubstringConstraint ContainsSubstring(string expected)
776         {
777             return (SubstringConstraint)this.Append(new SubstringConstraint(expected));
778         }
779
780         #endregion
781
782         #region StartsWith
783
784         /// <summary>
785         /// Returns a constraint that succeeds if the actual
786         /// value starts with the substring supplied as an argument.
787         /// </summary>
788         public StartsWithConstraint StartWith(string expected)
789         {
790             return (StartsWithConstraint)this.Append(new StartsWithConstraint(expected));
791         }
792
793         /// <summary>
794         /// Returns a constraint that succeeds if the actual
795         /// value starts with the substring supplied as an argument.
796         /// </summary>
797         public StartsWithConstraint StartsWith(string expected)
798         {
799             return (StartsWithConstraint)this.Append(new StartsWithConstraint(expected));
800         }
801
802         /// <summary>
803         /// Returns a constraint that succeeds if the actual
804         /// value starts with the substring supplied as an argument.
805         /// </summary>
806         [Obsolete("Deprecated, use Does.StartWith or StartsWith")]
807         public StartsWithConstraint StringStarting(string expected)
808         {
809             return (StartsWithConstraint)this.Append(new StartsWithConstraint(expected));
810         }
811
812         #endregion
813
814         #region EndsWith
815
816         /// <summary>
817         /// Returns a constraint that succeeds if the actual
818         /// value ends with the substring supplied as an argument.
819         /// </summary>
820         public EndsWithConstraint EndWith(string expected)
821         {
822             return (EndsWithConstraint)this.Append(new EndsWithConstraint(expected));
823         }
824
825         /// <summary>
826         /// Returns a constraint that succeeds if the actual
827         /// value ends with the substring supplied as an argument.
828         /// </summary>
829         public EndsWithConstraint EndsWith(string expected)
830         {
831             return (EndsWithConstraint)this.Append(new EndsWithConstraint(expected));
832         }
833
834         /// <summary>
835         /// Returns a constraint that succeeds if the actual
836         /// value ends with the substring supplied as an argument.
837         /// </summary>
838         [Obsolete("Deprecated, use Does.EndWith or EndsWith")]
839         public EndsWithConstraint StringEnding(string expected)
840         {
841             return (EndsWithConstraint)this.Append(new EndsWithConstraint(expected));
842         }
843
844         #endregion
845
846         #region Matches
847
848         /// <summary>
849         /// Returns a constraint that succeeds if the actual
850         /// value matches the regular expression supplied as an argument.
851         /// </summary>
852         public RegexConstraint Match(string pattern)
853         {
854             return (RegexConstraint)this.Append(new RegexConstraint(pattern));
855         }
856
857         /// <summary>
858         /// Returns a constraint that succeeds if the actual
859         /// value matches the regular expression supplied as an argument.
860         /// </summary>
861         public RegexConstraint Matches(string pattern)
862         {
863             return (RegexConstraint)this.Append(new RegexConstraint(pattern));
864         }
865
866         /// <summary>
867         /// Returns a constraint that succeeds if the actual
868         /// value matches the regular expression supplied as an argument.
869         /// </summary>
870         [Obsolete("Deprecated, use Does.Match or Matches")]
871         public RegexConstraint StringMatching(string pattern)
872         {
873             return (RegexConstraint)this.Append(new RegexConstraint(pattern));
874         }
875
876         #endregion
877         
878 #if !PORTABLE
879         #region SamePath
880
881         /// <summary>
882         /// Returns a constraint that tests whether the path provided 
883         /// is the same as an expected path after canonicalization.
884         /// </summary>
885         public SamePathConstraint SamePath(string expected)
886         {
887             return (SamePathConstraint)this.Append(new SamePathConstraint(expected));
888         }
889
890         #endregion
891
892         #region SubPath
893
894         /// <summary>
895         /// Returns a constraint that tests whether the path provided 
896         /// is the a subpath of the expected path after canonicalization.
897         /// </summary>
898         public SubPathConstraint SubPathOf(string expected)
899         {
900             return (SubPathConstraint)this.Append(new SubPathConstraint(expected));
901         }
902
903         #endregion
904
905         #region SamePathOrUnder
906
907         /// <summary>
908         /// Returns a constraint that tests whether the path provided 
909         /// is the same path or under an expected path after canonicalization.
910         /// </summary>
911         public SamePathOrUnderConstraint SamePathOrUnder(string expected)
912         {
913             return (SamePathOrUnderConstraint)this.Append(new SamePathOrUnderConstraint(expected));
914         }
915
916         #endregion
917 #endif
918
919         #region InRange
920
921         /// <summary>
922         /// Returns a constraint that tests whether the actual value falls 
923         /// within a specified range.
924         /// </summary>
925         public RangeConstraint InRange(IComparable from, IComparable to)
926         {
927             return (RangeConstraint)this.Append(new RangeConstraint(from, to));
928         }
929
930         #endregion
931
932         #region Exist
933
934 #if !SILVERLIGHT && !PORTABLE
935         /// <summary>
936         /// Returns a constraint that succeeds if the value
937         /// is a file or directory and it exists.
938         /// </summary>
939         public Constraint Exist
940         {
941             get { return Append(new FileOrDirectoryExistsConstraint()); }
942         }
943 #endif
944
945         #endregion
946
947     }
948 }