From: <gc...@us...> - 2003-02-26 17:23:40
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Security/Principal In directory sc8-pr-cvs1:/tmp/cvs-serv10457/DotNetMock.Tests/Security/Principal Added Files: MockIPrincipalTests.cs Log Message: --- NEW FILE: MockIPrincipalTests.cs --- using System; using System.Security.Principal; using NUnit.Framework; using DotNetMock.Security.Principal; namespace DotNetMock.Tests.Security.Principal { [TestFixture] public class MockIPrincipalTests { private MockIPrincipal mockPrincipal = null; [SetUp] public void Init() { mockPrincipal = new MockIPrincipal(); } [TearDown] public void Destroy() { mockPrincipal = null; } [Test] public void ExpectedIdentity() { IIdentity expectedIdentity = new System.Security.Principal.GenericIdentity("ExpectedIdentity"); mockPrincipal.SetExpectedIdentity( expectedIdentity ); Assertion.AssertEquals( "Identities don't equal.", expectedIdentity, mockPrincipal.Identity ); } [Test] [ExpectedException(typeof(AssertionException))] public void ExpectedIdentityFails() { IIdentity expectedIdentity = new System.Security.Principal.GenericIdentity("ExpectedIdentity" ); Assertion.AssertEquals( "Identities don't equal", expectedIdentity, mockPrincipal.Identity ); } [Test] public void IsInRole() { String role = "Manager"; mockPrincipal.AddExpectedRole( role ); Assertion.Assert( "Principal is not in role: " + role, mockPrincipal.IsInRole( role ) ); } [Test] public void IsInRoleInValid() { Assertion.Assert( "Principal is in role!", !mockPrincipal.IsInRole( "Employee" ) ); } [Test] public void IsInRoleMultiple() { String[] roles = new String[] { "Manager", "CEO" }; mockPrincipal.AddExpectedRoles( roles ); Assertion.Assert( "Principal is not in role.", mockPrincipal.IsInRole( "CEO" ) ); Assertion.Assert( "Principal is not in role.", mockPrincipal.IsInRole( "Manager" ) ); } [Test] public void IsInRoleCalls() { mockPrincipal.SetExpectedIsInRoleCount( 2 ); mockPrincipal.IsInRole( "" ); mockPrincipal.IsInRole( "" ); mockPrincipal.Verify(); } } } |