2 // AbstractTestFixture.cs
5 // Jb Evain (jbevain@gmail.com)
9 // Permission is hereby granted, free of charge, to any person obtaining
10 // a copy of this software and associated documentation files (the
11 // "Software"), to deal in the Software without restriction, including
12 // without limitation the rights to use, copy, modify, merge, publish,
13 // distribute, sublicense, and/or sell copies of the Software, and to
14 // permit persons to whom the Software is furnished to do so, subject to
15 // the following conditions:
17 // The above copyright notice and this permission notice shall be
18 // included in all copies or substantial portions of the Software.
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 namespace Mono
.Linker
.Tests
{
36 using NUnit
.Framework
;
38 public abstract class AbstractTestFixture
{
40 string _testCasesRoot
;
45 protected LinkContext Context
{
46 get { return _context; }
47 set { _context = value; }
50 protected Pipeline Pipeline
{
51 get { return _pipeline; }
52 set { _pipeline = value; }
55 public string TestCasesRoot
{
56 get { return _testCasesRoot; }
57 set { _testCasesRoot = value; }
60 public string TestCase
{
61 get { return _testCase; }
62 set { _testCase = value; }
66 public virtual void SetUp ()
68 _pipeline
= GetPipeline ();
72 public virtual void TearDown ()
76 protected virtual Pipeline
GetPipeline ()
78 return new Pipeline ();
81 protected virtual LinkContext
GetContext ()
83 LinkContext context
= new LinkContext (_pipeline
);
84 context
.OutputDirectory
= GetOutputPath ();
85 context
.CoreAction
= AssemblyAction
.Copy
;
89 protected string GetOutputPath ()
96 protected string GetTestCasePath ()
101 Path
.Combine (Environment
.CurrentDirectory
,
102 Path
.Combine ("..", "..")),
104 Environment
.CurrentDirectory
,
112 protected virtual void RunTest (string testCase
)
114 _testCase
= testCase
;
115 _context
= GetContext ();
118 protected virtual void Run ()
120 string cd
= Environment
.CurrentDirectory
;
121 Environment
.CurrentDirectory
= GetTestCasePath ();
123 _pipeline
.Process (_context
);
125 Environment
.CurrentDirectory
= cd
;
129 protected static string GetAssemblyFileName (AssemblyDefinition asm
)
131 return asm
.Name
.Name
+ (asm
.Kind
== AssemblyKind
.Dll
? ".dll" : ".exe");