From: <gc...@us...> - 2003-03-11 20:05:27
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Security/Principal In directory sc8-pr-cvs1:/tmp/cvs-serv9039/Security/Principal Added Files: MockIIdentityTests.cs MockIPrincipalTests.cs Log Message: --- NEW FILE: MockIIdentityTests.cs --- using System; using System.Security.Principal; using NUnit.Framework; using DotNetMock.Security.Principal; namespace DotNetMock.Tests.Security.Principal { [TestFixture] public class MockIdentityTests { private MockIIdentity mockIIdentity = null; [SetUp] public void Init() { mockIIdentity = new MockIIdentity(); } [TearDown] public void Destroy() { mockIIdentity = null; } [Test] public void AuthenticationType() { mockIIdentity.SetExpectedAuthenticationType( "NTLM" ); Assertion.AssertEquals( "NTLM", mockIIdentity.AuthenticationType ); } [Test] public void IsAuthenticated() { mockIIdentity.SetExpectedIsAuthenticated( true ); Assertion.Assert( mockIIdentity.IsAuthenticated ); } [Test] public void Name() { mockIIdentity.SetExpectedName( "Joe User" ); Assertion.AssertEquals( "Joe User", mockIIdentity.Name ); } } } --- 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(); } } } |