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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
|
using System;
using NUnit.Framework;
using Mono.Addins;
using System.IO;
using SimpleApp;
namespace UnitTests
{
[TestFixture()]
public class TestLoadUnload: TestBase
{
[Test()]
public void TestDisable ()
{
Addin ainfo;
Assert.AreEqual (4, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 1");
ainfo = AddinManager.Registry.GetAddin ("SimpleApp.HelloWorldExtension");
Assert.IsNotNull (ainfo, "t1");
Assert.IsTrue (ainfo.Enabled, "t1.1");
ainfo.Enabled = false;
Assert.IsFalse (ainfo.Enabled, "t1.2");
Assert.AreEqual (3, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 2");
ainfo = AddinManager.Registry.GetAddin ("SimpleApp.FileContentExtension");
Assert.IsNotNull (ainfo, "t3");
Assert.IsTrue (ainfo.Enabled, "t3.1");
ainfo.Enabled = false;
Assert.IsFalse (ainfo.Enabled, "t3.2");
Assert.AreEqual (2, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 3");
ainfo = AddinManager.Registry.GetAddin ("SimpleApp.SystemInfoExtension");
Assert.IsNotNull (ainfo, "t5");
Assert.IsTrue (ainfo.Enabled, "t5.1");
ainfo.Enabled = false;
Assert.IsFalse (ainfo.Enabled, "t5.2");
Assert.AreEqual (0, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 4");
ainfo = AddinManager.Registry.GetAddin ("SimpleApp.CommandExtension");
Assert.IsNotNull (ainfo, "t2");
Assert.IsTrue (ainfo.Enabled, "t2.1");
ainfo.Enabled = false;
Assert.IsFalse (ainfo.Enabled, "t2.2");
Assert.AreEqual (0, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 5");
}
[Test()]
public void TestEnable ()
{
Assert.AreEqual (0, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 1");
Assert.IsFalse (AddinManager.Registry.IsAddinEnabled ("SimpleApp.HelloWorldExtension"), "t1");
AddinManager.Registry.EnableAddin ("SimpleApp.HelloWorldExtension,0.1.0");
Assert.IsTrue (AddinManager.Registry.IsAddinEnabled ("SimpleApp.HelloWorldExtension"), "t1.1");
Assert.AreEqual (1, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 2");
Assert.IsFalse (AddinManager.Registry.IsAddinEnabled ("SimpleApp.CommandExtension"), "t2");
AddinManager.Registry.EnableAddin ("SimpleApp.CommandExtension,0.1.0");
Assert.IsTrue (AddinManager.Registry.IsAddinEnabled ("SimpleApp.CommandExtension"), "t2.1");
Assert.AreEqual (1, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 3");
Assert.IsFalse (AddinManager.Registry.IsAddinEnabled ("SimpleApp.SystemInfoExtension"), "t3");
AddinManager.Registry.EnableAddin ("SimpleApp.SystemInfoExtension,0.1.0");
Assert.IsTrue (AddinManager.Registry.IsAddinEnabled ("SimpleApp.SystemInfoExtension"), "t3.1");
Assert.AreEqual (3, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 4");
Assert.IsFalse (AddinManager.Registry.IsAddinEnabled ("SimpleApp.FileContentExtension"), "t4");
AddinManager.Registry.EnableAddin ("SimpleApp.FileContentExtension,0.1.0");
Assert.IsTrue (AddinManager.Registry.IsAddinEnabled ("SimpleApp.FileContentExtension"), "t4.1");
Assert.AreEqual (4, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 5");
}
[Test()]
public void TestDisableWithDeps ()
{
Addin ainfo;
Assert.AreEqual (4, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 1");
ainfo = AddinManager.Registry.GetAddin ("SimpleApp.HelloWorldExtension");
Assert.IsNotNull (ainfo, "t1");
Assert.IsTrue (ainfo.Enabled, "t1.1");
ainfo.Enabled = false;
Assert.IsFalse (ainfo.Enabled, "t1.2");
Assert.AreEqual (3, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 2");
ainfo = AddinManager.Registry.GetAddin ("SimpleApp.CommandExtension");
Assert.IsNotNull (ainfo, "t2");
Assert.IsTrue (ainfo.Enabled, "t2.1");
ainfo.Enabled = false;
Assert.IsFalse (ainfo.Enabled, "t2.2");
// SystemInfoExtension depends on CommandExtension, so it should be disabled after disabling CommandExtension
Assert.AreEqual (1, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 3");
ainfo = AddinManager.Registry.GetAddin ("SimpleApp.SystemInfoExtension");
Assert.IsNotNull (ainfo, "t4");
Assert.IsFalse (ainfo.Enabled, "t4.1");
// FileContentExtension depends on SystemInfoExtension, but the dependency is optional
ainfo = AddinManager.Registry.GetAddin ("SimpleApp.FileContentExtension");
Assert.IsNotNull (ainfo, "t5");
Assert.IsTrue (ainfo.Enabled, "t5.1");
ainfo.Enabled = false;
Assert.IsFalse (ainfo.Enabled, "t5.2");
Assert.AreEqual (0, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 4");
}
[Test()]
public void TestEnableWithDeps ()
{
Addin ainfo;
Assert.AreEqual (0, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 1");
ainfo = AddinManager.Registry.GetAddin ("SimpleApp.HelloWorldExtension");
Assert.IsNotNull (ainfo, "t1");
Assert.IsFalse (ainfo.Enabled, "t1.1");
ainfo.Enabled = true;
Assert.IsTrue (ainfo.Enabled, "t1.2");
Assert.AreEqual (1, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 2");
ainfo = AddinManager.Registry.GetAddin ("SimpleApp.FileContentExtension");
Assert.IsNotNull (ainfo, "t3");
Assert.IsFalse (ainfo.Enabled, "t3.1");
ainfo.Enabled = true;
Assert.IsTrue (ainfo.Enabled, "t3.2");
Assert.AreEqual (2, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 3");
ainfo = AddinManager.Registry.GetAddin ("SimpleApp.SystemInfoExtension");
Assert.IsNotNull (ainfo, "t5");
Assert.IsFalse (ainfo.Enabled, "t5.1");
ainfo.Enabled = true;
Assert.IsTrue (ainfo.Enabled, "t5.2");
Assert.AreEqual (4, AddinManager.GetExtensionNodes ("/SimpleApp/Writers").Count, "count 4");
ainfo = AddinManager.Registry.GetAddin ("SimpleApp.CommandExtension");
Assert.IsNotNull (ainfo, "t2");
Assert.IsTrue (ainfo.Enabled, "t2.1");
}
[Test()]
public void TestCurrentAddin ()
{
Assert.AreEqual ("SimpleApp.Core,0.1.0", AddinManager.CurrentAddin.ToString ());
InstanceExtensionNode node = (InstanceExtensionNode) AddinManager.GetExtensionNode ("/SimpleApp/Writers/HelloWorldExtension.HelloWorldWriter");
Assert.IsNotNull (node, "t1");
IWriter w = (IWriter) node.CreateInstance ();
Assert.AreEqual ("SimpleApp.HelloWorldExtension,0.1.0", w.Test ("currentAddin"));
}
}
}
|