File: IsolatedStorageFilePermissionTest.cs

package info (click to toggle)
mono 2.6.7-5.1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 327,344 kB
  • ctags: 413,649
  • sloc: cs: 2,471,883; xml: 1,768,594; ansic: 350,665; sh: 13,644; makefile: 8,640; perl: 1,784; asm: 717; cpp: 209; python: 146; sql: 81; sed: 16
file content (400 lines) | stat: -rw-r--r-- 19,370 bytes parent folder | download | duplicates (8)
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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
//
// IsolatedStorageFilePermissionTest.cs - NUnit Test Cases for IsolatedStorageFilePermission
//
// Author:
//	Sebastien Pouliot  <sebastien@ximian.com>
//
// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
// 
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
// 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

using NUnit.Framework;
using System;
using System.Security;
using System.Security.Permissions;

namespace MonoTests.System.Security.Permissions {

	[TestFixture]
	public class IsolatedStorageFilePermissionTest {

		[Test]
		public void PermissionStateNone ()
		{
			IsolatedStorageFilePermission isfp = new IsolatedStorageFilePermission (PermissionState.None);
			Assert.AreEqual (IsolatedStorageContainment.None, isfp.UsageAllowed, "UsageAllowed");
			Assert.AreEqual (0, isfp.UserQuota, "UserQuota");

			SecurityElement se = isfp.ToXml ();
			// only class and version are present
			Assert.AreEqual ("None", se.Attribute ("Allowed"), "Xml-Allowed");
			Assert.IsNull (se.Children, "Xml-Children");

			IsolatedStorageFilePermission copy = (IsolatedStorageFilePermission)isfp.Copy ();
			Assert.IsFalse (Object.ReferenceEquals (isfp, copy), "ReferenceEquals");
			Assert.AreEqual (isfp.UsageAllowed, copy.UsageAllowed, "UsageAllowed");
			Assert.AreEqual (isfp.UserQuota, copy.UserQuota, "UserQuota");
		}

		[Test]
		public void PermissionStateUnrestricted ()
		{
			IsolatedStorageFilePermission isfp = new IsolatedStorageFilePermission (PermissionState.Unrestricted);
			Assert.AreEqual (IsolatedStorageContainment.UnrestrictedIsolatedStorage, isfp.UsageAllowed, "UsageAllowed");
			Assert.AreEqual (Int64.MaxValue, isfp.UserQuota, "UserQuota");

			SecurityElement se = isfp.ToXml ();
			// only class and version are present
			Assert.AreEqual ("true", se.Attribute ("Unrestricted"), "Xml-Unrestricted");
			Assert.IsNull (se.Children, "Xml-Children");

			IsolatedStorageFilePermission copy = (IsolatedStorageFilePermission)isfp.Copy ();
			Assert.IsFalse (Object.ReferenceEquals (isfp, copy), "ReferenceEquals");
			Assert.AreEqual (isfp.UsageAllowed, copy.UsageAllowed, "UsageAllowed");
			Assert.AreEqual (isfp.UserQuota, copy.UserQuota, "UserQuota");
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void PermissionStateInvalid ()
		{
			IsolatedStorageFilePermission isfp = new IsolatedStorageFilePermission ((PermissionState)2);
		}

		[Test]
		public void Intersect ()
		{
			IsolatedStorageFilePermission empty = new IsolatedStorageFilePermission (PermissionState.None);
			IsolatedStorageFilePermission intersect = (IsolatedStorageFilePermission)empty.Intersect (null);
			Assert.IsNull (intersect, "empty N null");

			intersect = (IsolatedStorageFilePermission)empty.Intersect (empty);
			Assert.IsNull (intersect, "empty N empty");

			IsolatedStorageFilePermission unrestricted = new IsolatedStorageFilePermission (PermissionState.Unrestricted);
			intersect = (IsolatedStorageFilePermission)unrestricted.Intersect (null);
			Assert.IsNull (intersect, "unrestricted N null");

			intersect = (IsolatedStorageFilePermission)unrestricted.Intersect (empty);
			Assert.IsNotNull (intersect, "unrestricted N empty");

			intersect = (IsolatedStorageFilePermission)unrestricted.Intersect (unrestricted);
			Assert.IsNotNull (intersect, "unrestricted N unrestricted");
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void Intersect_DifferentPermissions ()
		{
			IsolatedStorageFilePermission a = new IsolatedStorageFilePermission (PermissionState.None);
			SecurityPermission b = new SecurityPermission (PermissionState.None);
			a.Intersect (b);
		}

		[Test]
		public void IsSubsetOf ()
		{
			IsolatedStorageFilePermission empty = new IsolatedStorageFilePermission (PermissionState.None);
			Assert.IsTrue (empty.IsSubsetOf (null), "empty.IsSubsetOf (null)");

			IsolatedStorageFilePermission unrestricted = new IsolatedStorageFilePermission (PermissionState.Unrestricted);
			Assert.IsFalse (unrestricted.IsSubsetOf (null), "unrestricted.IsSubsetOf (null)");
			Assert.IsFalse (unrestricted.IsSubsetOf (empty), "unrestricted.IsSubsetOf (empty)");
			Assert.IsTrue (empty.IsSubsetOf (unrestricted), "empty.IsSubsetOf (unrestricted)");
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void IsSubsetOf_DifferentPermissions ()
		{
			IsolatedStorageFilePermission a = new IsolatedStorageFilePermission (PermissionState.None);
			SecurityPermission b = new SecurityPermission (PermissionState.None);
			a.IsSubsetOf (b);
		}

		[Test]
		public void Union ()
		{
			IsolatedStorageFilePermission empty = new IsolatedStorageFilePermission (PermissionState.None);
			IsolatedStorageFilePermission union = (IsolatedStorageFilePermission)empty.Union (null);
			Assert.IsNotNull (union, "empty U null");
			Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-1");
			Assert.IsFalse (Object.ReferenceEquals (empty, union), "ReferenceEquals-1");

			union = (IsolatedStorageFilePermission)empty.Union (empty);
			Assert.IsNotNull (union, "empty U empty");
			Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-2");
			Assert.IsFalse (Object.ReferenceEquals (empty, union), "ReferenceEquals-2");

			IsolatedStorageFilePermission unrestricted = new IsolatedStorageFilePermission (PermissionState.Unrestricted);
			union = (IsolatedStorageFilePermission)unrestricted.Union (null);
			Assert.IsNotNull (union, "unrestricted U null");
			Assert.IsTrue (union.IsUnrestricted (), "IsUnrestricted-3");
			Assert.IsFalse (Object.ReferenceEquals (unrestricted, union), "ReferenceEquals-3");

			union = (IsolatedStorageFilePermission)unrestricted.Union (empty);
			Assert.IsNotNull (union, "unrestricted U empty");
			Assert.IsTrue (union.IsUnrestricted (), "IsUnrestricted-4");
			Assert.IsFalse (Object.ReferenceEquals (unrestricted, union), "ReferenceEquals-4");

			union = (IsolatedStorageFilePermission)unrestricted.Union (unrestricted);
			Assert.IsNotNull (union, "unrestricted U unrestricted");
			Assert.IsTrue (union.IsUnrestricted (), "IsUnrestricted-5");
			Assert.IsFalse (Object.ReferenceEquals (unrestricted, union), "ReferenceEquals-5");
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void Union_DifferentPermissions ()
		{
			IsolatedStorageFilePermission a = new IsolatedStorageFilePermission (PermissionState.None);
			SecurityPermission b = new SecurityPermission (PermissionState.None);
			a.Union (b);
		}

		[Test]
		public void UsageAllowedQuota ()
		{
			IsolatedStorageFilePermission empty = new IsolatedStorageFilePermission (PermissionState.None);
			IsolatedStorageFilePermission small = new IsolatedStorageFilePermission (PermissionState.None);
			small.UsageAllowed = IsolatedStorageContainment.DomainIsolationByUser;
			small.UserQuota = 1;
			IsolatedStorageFilePermission union = (IsolatedStorageFilePermission)empty.Union (small);
			Assert.AreEqual (IsolatedStorageContainment.DomainIsolationByUser, union.UsageAllowed, "DomainIsolationByUser");
			Assert.AreEqual (1, union.UserQuota, "1");
			Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-1");
			Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-1a");
			Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-1b");
			Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-1c");
			IsolatedStorageFilePermission intersect = (IsolatedStorageFilePermission)union.Intersect (small);
			Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-1");
			Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-1");

			small.UsageAllowed = IsolatedStorageContainment.AssemblyIsolationByUser;
			small.UserQuota = 2;
			union = (IsolatedStorageFilePermission)union.Union (small);
			Assert.AreEqual (IsolatedStorageContainment.AssemblyIsolationByUser, union.UsageAllowed, "AssemblyIsolationByUser");
			Assert.AreEqual (2, union.UserQuota, "2");
			Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-2");
			Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-2a");
			Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-2b");
			Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-2c");
			intersect = (IsolatedStorageFilePermission)union.Intersect (small);
			Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-2");
			Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-2");
#if NET_2_0
			small.UsageAllowed = IsolatedStorageContainment.ApplicationIsolationByUser;
			small.UserQuota = 3;
			union = (IsolatedStorageFilePermission)union.Union (small);
			Assert.AreEqual (IsolatedStorageContainment.AssemblyIsolationByUser, union.UsageAllowed, "ApplicationIsolationByUser");
			Assert.AreEqual (3, union.UserQuota, "3");
			Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-3");
			Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-3a");
			Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-3b");
			Assert.IsFalse (union.IsSubsetOf (small), "IsSubset-3c");
			intersect = (IsolatedStorageFilePermission)union.Intersect (small);
			Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-3");
			Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-3");

			small.UsageAllowed = IsolatedStorageContainment.DomainIsolationByMachine;
			small.UserQuota = 4;
			union = (IsolatedStorageFilePermission)union.Union (small);
			Assert.AreEqual (IsolatedStorageContainment.DomainIsolationByMachine, union.UsageAllowed, "DomainIsolationByMachine");
			Assert.AreEqual (4, union.UserQuota, "4");
			Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-4");
			Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-4a");
			Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-4b");
			Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-4c");
			intersect = (IsolatedStorageFilePermission)union.Intersect (small);
			Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-4");
			Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-4");

			small.UsageAllowed = IsolatedStorageContainment.AssemblyIsolationByMachine;
			small.UserQuota = 5;
			union = (IsolatedStorageFilePermission)union.Union (small);
			Assert.AreEqual (IsolatedStorageContainment.AssemblyIsolationByMachine, union.UsageAllowed, "AssemblyIsolationByMachine");
			Assert.AreEqual (5, union.UserQuota, "5");
			Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-5");
			Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-5a");
			Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-5b");
			Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-5c");
			intersect = (IsolatedStorageFilePermission)union.Intersect (small);
			Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-5");
			Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-5");

			small.UsageAllowed = IsolatedStorageContainment.ApplicationIsolationByMachine;
			small.UserQuota = 6;
			union = (IsolatedStorageFilePermission)union.Union (small);
			Assert.AreEqual (IsolatedStorageContainment.ApplicationIsolationByMachine, union.UsageAllowed, "ApplicationIsolationByMachine");
			Assert.AreEqual (6, union.UserQuota, "6");
			Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-6");
			Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-6a");
			Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-6b");
			Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-6c");
			intersect = (IsolatedStorageFilePermission)union.Intersect (small);
			Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-6");
			Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-6");
#endif
			small.UsageAllowed = IsolatedStorageContainment.DomainIsolationByRoamingUser;
			small.UserQuota = 7;
			union = (IsolatedStorageFilePermission)union.Union (small);
			Assert.AreEqual (IsolatedStorageContainment.DomainIsolationByRoamingUser, union.UsageAllowed, "DomainIsolationByRoamingUser");
			Assert.AreEqual (7, union.UserQuota, "7a");
			Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-7a");
			Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-7a");
			Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-7b");
			Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-7c");
			intersect = (IsolatedStorageFilePermission)union.Intersect (small);
			Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-7");
			Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-7");

			// can't go back ;-)
			small.UsageAllowed = IsolatedStorageContainment.DomainIsolationByUser;
			small.UserQuota = 1;
			union = (IsolatedStorageFilePermission)union.Union (small);
			Assert.AreEqual (IsolatedStorageContainment.DomainIsolationByRoamingUser, union.UsageAllowed, "DomainIsolationByRoamingUser");
			Assert.AreEqual (7, union.UserQuota, "7b");
			Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-7b");

			small.UsageAllowed = IsolatedStorageContainment.AssemblyIsolationByRoamingUser;
			small.UserQuota = 7; // no change
			union = (IsolatedStorageFilePermission)union.Union (small);
			Assert.AreEqual (IsolatedStorageContainment.AssemblyIsolationByRoamingUser, union.UsageAllowed, "AssemblyIsolationByRoamingUser");
			Assert.AreEqual (7, union.UserQuota, "7c");
			Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-7c");
#if NET_2_0
			small.UsageAllowed = IsolatedStorageContainment.ApplicationIsolationByRoamingUser;
			small.UserQuota = 8;
			union = (IsolatedStorageFilePermission)union.Union (small);
			Assert.AreEqual (IsolatedStorageContainment.ApplicationIsolationByRoamingUser, union.UsageAllowed, "ApplicationIsolationByRoamingUser");
			Assert.AreEqual (8, union.UserQuota, "8");
			Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-8");
			Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-8a");
			Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-8b");
			Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-8c");
			intersect = (IsolatedStorageFilePermission)union.Intersect (small);
			Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-8");
			Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-8");
#endif
			small.UsageAllowed = IsolatedStorageContainment.AdministerIsolatedStorageByUser;
			small.UserQuota = 9;
			union = (IsolatedStorageFilePermission)union.Union (small);
			Assert.AreEqual (IsolatedStorageContainment.AdministerIsolatedStorageByUser, union.UsageAllowed, "AdministerIsolatedStorageByUser");
			Assert.AreEqual (9, union.UserQuota, "9");
			Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-9");
			Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-9a");
			Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-9b");
			Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-9c");
			intersect = (IsolatedStorageFilePermission)union.Intersect (small);
			Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-9");
			Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-9");

			small.UsageAllowed = IsolatedStorageContainment.UnrestrictedIsolatedStorage;
			small.UserQuota = 10;
			union = (IsolatedStorageFilePermission)union.Union (small);
			Assert.AreEqual (IsolatedStorageContainment.UnrestrictedIsolatedStorage, union.UsageAllowed, "UnrestrictedIsolatedStorage");
			Assert.AreEqual (Int64.MaxValue, union.UserQuota, "10");
			Assert.IsTrue (union.IsUnrestricted (), "IsUnrestricted-10");
			Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-10a");
			Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-10b");
			Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-10c");
			intersect = (IsolatedStorageFilePermission)union.Intersect (small);
			Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-10");
			Assert.IsFalse ((small.UserQuota == intersect.UserQuota), "Intersect-UserQuota-10");
		}

		[Test]
		[ExpectedException (typeof (ArgumentNullException))]
		public void FromXml_Null ()
		{
			IsolatedStorageFilePermission isfp = new IsolatedStorageFilePermission (PermissionState.None);
			isfp.FromXml (null);
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void FromXml_WrongTag ()
		{
			IsolatedStorageFilePermission isfp = new IsolatedStorageFilePermission (PermissionState.None);
			SecurityElement se = isfp.ToXml ();
			se.Tag = "IMono";
			isfp.FromXml (se);
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void FromXml_WrongTagCase ()
		{
			IsolatedStorageFilePermission isfp = new IsolatedStorageFilePermission (PermissionState.None);
			SecurityElement se = isfp.ToXml ();
			se.Tag = "IPERMISSION"; // instead of IPermission
			isfp.FromXml (se);
		}

		[Test]
		public void FromXml_WrongClass ()
		{
			IsolatedStorageFilePermission isfp = new IsolatedStorageFilePermission (PermissionState.None);
			SecurityElement se = isfp.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("class", "Wrong" + se.Attribute ("class"));
			w.AddAttribute ("version", se.Attribute ("version"));
			isfp.FromXml (w);
			// doesn't care of the class name at that stage
			// anyway the class has already be created so...
		}

		[Test]
		public void FromXml_NoClass ()
		{
			IsolatedStorageFilePermission isfp = new IsolatedStorageFilePermission (PermissionState.None);
			SecurityElement se = isfp.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("version", se.Attribute ("version"));
			isfp.FromXml (w);
			// doesn't even care of the class attribute presence
		}

		[Test]
		[ExpectedException (typeof (ArgumentException))]
		public void FromXml_WrongVersion ()
		{
			IsolatedStorageFilePermission isfp = new IsolatedStorageFilePermission (PermissionState.None);
			SecurityElement se = isfp.ToXml ();
			se.Attributes.Remove ("version");
			se.Attributes.Add ("version", "2");
			isfp.FromXml (se);
		}

		[Test]
		public void FromXml_NoVersion ()
		{
			IsolatedStorageFilePermission isfp = new IsolatedStorageFilePermission (PermissionState.None);
			SecurityElement se = isfp.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("class", se.Attribute ("class"));
			isfp.FromXml (w);
		}
	}
}