[NUI] Rebase develnui (DevelNUI only patches --> master) (#3910)
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Devel.Tests.Ubuntu / nunit.framework / Constraints / OrConstraint.cs
1 // ***********************************************************************
2 // Copyright (c) 2007 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 #define PORTABLE
23 #define TIZEN
24 #define NUNIT_FRAMEWORK
25 #define NUNITLITE
26 #define NET_4_5
27 #define PARALLEL
28 namespace NUnit.Framework.Constraints
29 {
30     /// <summary>
31     /// OrConstraint succeeds if either member succeeds
32     /// </summary>
33     public class OrConstraint : BinaryConstraint
34     {
35         /// <summary>
36         /// Create an OrConstraint from two other constraints
37         /// </summary>
38         /// <param name="left">The first constraint</param>
39         /// <param name="right">The second constraint</param>
40         public OrConstraint(IConstraint left, IConstraint right) : base(left, right) { }
41
42         /// <summary>
43         /// Gets text describing a constraint
44         /// </summary>
45         public override string Description
46         {
47             get { return Left.Description + " or " + Right.Description; }
48         }
49
50         /// <summary>
51         /// Apply the member constraints to an actual value, succeeding 
52         /// succeeding as soon as one of them succeeds.
53         /// </summary>
54         /// <param name="actual">The actual value</param>
55         /// <returns>True if either constraint succeeded</returns>
56         public override ConstraintResult ApplyTo<TActual>(TActual actual)
57         {
58             bool hasSucceeded = Left.ApplyTo(actual).IsSuccess || Right.ApplyTo(actual).IsSuccess;
59             return new ConstraintResult(this, actual, hasSucceeded);
60         }
61     }
62 }