[NUI] Rebase develnui (DevelNUI only patches --> master) (#3910)
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Devel.Tests.Ubuntu / nunit.framework / Internal / Filters / NotFilter.cs
1 // ***********************************************************************
2 // Copyright (c) 2007-2015 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 NUnit.Framework.Interfaces;
31
32 namespace NUnit.Framework.Internal.Filters
33 {
34     /// <summary>
35     /// NotFilter negates the operation of another filter
36     /// </summary>
37     //[Serializable]
38     public class NotFilter : TestFilter
39     {
40         /// <summary>
41         /// Construct a not filter on another filter
42         /// </summary>
43         /// <param name="baseFilter">The filter to be negated</param>
44         public NotFilter( TestFilter baseFilter)
45         {
46             BaseFilter = baseFilter;
47         }
48
49         /// <summary>
50         /// Gets the base filter
51         /// </summary>
52         public TestFilter BaseFilter { get; private set; }
53
54         /// <summary>
55         /// Determine if a particular test passes the filter criteria. The default 
56         /// implementation checks the test itself, its parents and any descendants.
57         /// 
58         /// Derived classes may override this method or any of the Match methods
59         /// to change the behavior of the filter.
60         /// </summary>
61         /// <param name="test">The test to which the filter is applied</param>
62         /// <returns>True if the test passes the filter, otherwise false</returns>
63         public override bool Pass(ITest test)
64         {
65             return !BaseFilter.Match (test) && !BaseFilter.MatchParent (test);
66         }
67
68         /// <summary>
69         /// Check whether the filter matches a test
70         /// </summary>
71         /// <param name="test">The test to be matched</param>
72         /// <returns>True if it matches, otherwise false</returns>
73         public override bool Match( ITest test )
74         {
75             return !BaseFilter.Match( test );
76         }
77
78         /// <summary>
79         /// Determine if a test matches the filter expicitly. That is, it must
80         /// be a direct match of the test itself or one of it's children.
81         /// </summary>
82         /// <param name="test">The test to which the filter is applied</param>
83         /// <returns>True if the test matches the filter explicityly, otherwise false</returns>
84         public override bool IsExplicitMatch(ITest test)
85         {
86             return false;
87         }
88
89         ///// <summary>
90         ///// Determine whether any descendant of the test matches the filter criteria.
91         ///// </summary>
92         ///// <param name="test">The test to be matched</param>
93         ///// <returns>True if at least one descendant matches the filter criteria</returns>
94         //protected override bool MatchDescendant(ITest test)
95         //{
96         //    if (!test.HasChildren || test.Tests == null || TopLevel && test.RunState == RunState.Explicit)
97         //        return false;
98
99         //    foreach (ITest child in test.Tests)
100         //    {
101         //        if (Match(child) || MatchDescendant(child))
102         //            return true;
103         //    }
104
105         //    return false;
106         //}     
107
108         /// <summary>
109         /// Adds an XML node
110         /// </summary>
111         /// <param name="parentNode">Parent node</param>
112         /// <param name="recursive">True if recursive</param>
113         /// <returns>The added XML node</returns>
114         public override TNode AddToXml(TNode parentNode, bool recursive)
115         {
116             TNode result = parentNode.AddElement("not");
117             if (recursive)
118                 BaseFilter.AddToXml(result, true);
119             return result;
120         }
121     }
122 }