2 // GenericPrincipalTest.cs - NUnit Test Cases for GenericPrincipal
5 // Sebastien Pouliot (spouliot@motus.com)
7 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
10 using NUnit
.Framework
;
12 using System
.Security
.Principal
;
14 namespace MonoTests
.System
.Security
.Principal
{
17 public class GenericPrincipalTest
: Assertion
{
20 [ExpectedException (typeof (ArgumentNullException
))]
21 public void NullIdentity ()
23 GenericPrincipal gp
= new GenericPrincipal (null, new string [5]);
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"));
36 public void IsInRole ()
38 GenericIdentity gi
= new GenericIdentity ("user");
39 string[] roles
= new string [5];
41 GenericPrincipal gp
= new GenericPrincipal (gi
, roles
);
43 Assert ("IsInRole (role added before constructor)", gp
.IsInRole ("role 1"));
44 Assert ("IsInRole (role added after constructor)", !gp
.IsInRole ("role 2"));