**** Merged from MCS ****
[mono-project.git] / mcs / class / corlib / Test / System.Security.Principal / GenericPrincipalTest.cs
blob91dbe0f7e5f6de04c01fbe33acd9c2764972d7b5
1 //
2 // GenericPrincipalTest.cs - NUnit Test Cases for GenericPrincipal
3 //
4 // Author:
5 // Sebastien Pouliot (spouliot@motus.com)
6 //
7 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
8 //
10 using NUnit.Framework;
11 using System;
12 using System.Security.Principal;
14 namespace MonoTests.System.Security.Principal {
16 [TestFixture]
17 public class GenericPrincipalTest : Assertion {
19 [Test]
20 [ExpectedException (typeof (ArgumentNullException))]
21 public void NullIdentity ()
23 GenericPrincipal gp = new GenericPrincipal (null, new string [5]);
26 [Test]
27 public void NullRoles ()
29 GenericIdentity gi = new GenericIdentity ("user");
30 GenericPrincipal gp = new GenericPrincipal (gi, null);
31 AssertEquals ("Identity", "user", gp.Identity.Name);
32 Assert ("NoRole.IsInRole(x)", !gp.IsInRole ("role 1"));
35 [Test]
36 public void IsInRole ()
38 GenericIdentity gi = new GenericIdentity ("user");
39 string[] roles = new string [5];
40 roles [0] = "role 1";
41 GenericPrincipal gp = new GenericPrincipal (gi, roles);
42 roles [1] = "role 2";
43 Assert ("IsInRole (role added before constructor)", gp.IsInRole ("role 1"));
44 Assert ("IsInRole (role added after constructor)", !gp.IsInRole ("role 2"));