[NUI] Rebase develnui (DevelNUI only patches --> master) (#3910)
[platform/core/csapi/tizenfx.git] / test / Tizen.NUI.Devel.Tests.Ubuntu / nunit.framework / Internal / Tests / TestMethod.cs
1 // ***********************************************************************
2 // Copyright (c) 2012 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.Collections.Generic;
30 using NUnit.Framework.Interfaces;
31 using NUnit.Framework.Internal.Commands;
32 using NUnit.Framework.Internal.Execution;
33
34 namespace NUnit.Framework.Internal
35 {
36     /// <summary>
37     /// The TestMethod class represents a Test implemented as a method.
38     /// </summary>
39     public class TestMethod : Test
40     {
41         #region Fields
42
43         /// <summary>
44         /// The ParameterSet used to create this test method
45         /// </summary>
46         internal TestCaseParameters parms;
47
48         #endregion
49
50         #region Constructor
51
52         /// <summary>
53         /// Initializes a new instance of the <see cref="TestMethod"/> class.
54         /// </summary>
55         /// <param name="method">The method to be used as a test.</param>
56         public TestMethod(IMethodInfo method) : base (method) { }
57
58         /// <summary>
59         /// Initializes a new instance of the <see cref="TestMethod"/> class.
60         /// </summary>
61         /// <param name="method">The method to be used as a test.</param>
62         /// <param name="parentSuite">The suite or fixture to which the new test will be added</param>
63         public TestMethod(IMethodInfo method, Test parentSuite) : base(method ) 
64         {
65             // Needed to give proper fullname to test in a parameterized fixture.
66             // Without this, the arguments to the fixture are not included.
67             if (parentSuite != null)
68                 FullName = parentSuite.FullName + "." + Name;
69         }
70
71         #endregion
72
73         #region Properties
74
75         internal bool HasExpectedResult
76         {
77             get { return parms != null && parms.HasExpectedResult; }
78         }
79
80         internal object ExpectedResult
81         {
82             get { return parms != null ? parms.ExpectedResult : null; }
83         }
84
85         internal object[] Arguments
86         {
87             get { return parms != null ? parms.Arguments : null; }
88         }
89
90         #endregion
91
92         #region Test Overrides
93
94         /// <summary>
95         /// Overridden to return a TestCaseResult.
96         /// </summary>
97         /// <returns>A TestResult for this test.</returns>
98         public override TestResult MakeTestResult()
99         {
100             return new TestCaseResult(this);
101         }
102
103         /// <summary>
104         /// Gets a bool indicating whether the current test
105         /// has any descendant tests.
106         /// </summary>
107         public override bool HasChildren
108         {
109             get { return false; }
110         }
111
112         /// <summary>
113         /// Returns a TNode representing the current result after
114         /// adding it as a child of the supplied parent node.
115         /// </summary>
116         /// <param name="parentNode">The parent node.</param>
117         /// <param name="recursive">If true, descendant results are included</param>
118         /// <returns></returns>
119         public override TNode AddToXml(TNode parentNode, bool recursive)
120         {
121             TNode thisNode = parentNode.AddElement(XmlElementName);
122
123             PopulateTestNode(thisNode, recursive);
124
125             thisNode.AddAttribute("seed", this.Seed.ToString());
126
127             return thisNode;
128         }
129
130         /// <summary>
131         /// Gets this test's child tests
132         /// </summary>
133         /// <value>A list of child tests</value>
134         public override IList<ITest> Tests
135         {
136             get { return new ITest[0]; }
137         }
138
139         /// <summary>
140         /// Gets the name used for the top-level element in the
141         /// XML representation of this test
142         /// </summary>
143         public override string XmlElementName
144         {
145             get { return "test-case"; }
146         }
147
148         /// <summary>
149         /// Returns the name of the method
150         /// </summary>
151         public override string MethodName
152         {
153             get { return Method.Name; }
154         }
155
156         #endregion
157     }
158 }