1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
using System;
using System.Collections;
using System.IO;
using NUnit.Framework;
namespace NUnit.Util.Tests
{
public class DomainManagerTests
{
static string path1 = TestPath("/test/bin/debug/test1.dll");
static string path2 = TestPath("/test/bin/debug/test2.dll");
static string path3 = TestPath("/test/utils/test3.dll");
[Test]
public void GetPrivateBinPath()
{
string[] assemblies = new string[] { path1, path2, path3 };
Assert.AreEqual(
TestPath("bin/debug") + Path.PathSeparator + TestPath("utils"),
DomainManager.GetPrivateBinPath(TestPath("/test"), assemblies));
}
[Test]
public void GetCommonAppBase_OneElement()
{
string[] assemblies = new string[] { path1 };
Assert.AreEqual(
TestPath("/test/bin/debug"),
DomainManager.GetCommonAppBase(assemblies));
}
[Test]
public void GetCommonAppBase_TwoElements_SameDirectory()
{
string[] assemblies = new string[] { path1, path2 };
Assert.AreEqual(
TestPath("/test/bin/debug"),
DomainManager.GetCommonAppBase(assemblies));
}
[Test]
public void GetCommonAppBase_TwoElements_DifferentDirectories()
{
string[] assemblies = new string[] { path1, path3 };
Assert.AreEqual(
TestPath("/test"),
DomainManager.GetCommonAppBase(assemblies));
}
[Test]
public void GetCommonAppBase_ThreeElements_DiferentDirectories()
{
string[] assemblies = new string[] { path1, path2, path3 };
Assert.AreEqual(
TestPath("/test"),
DomainManager.GetCommonAppBase(assemblies));
}
[Test]
public void UnloadUnloadedDomain()
{
AppDomain domain = AppDomain.CreateDomain("DomainManagerTests-domain");
AppDomain.Unload(domain);
DomainManager manager = new DomainManager();
manager.Unload(domain);
}
/// <summary>
/// Take a valid Linux path and make a valid windows path out of it
/// if we are on Windows. Change slashes to backslashes and, if the
/// path starts with a slash, add C: in front of it.
/// </summary>
private static string TestPath(string path)
{
if (Path.DirectorySeparatorChar != '/')
{
path = path.Replace('/', Path.DirectorySeparatorChar);
if (path[0] == Path.DirectorySeparatorChar)
path = "C:" + path;
}
return path;
}
}
}
|