This list is closed, nobody may subscribe to it.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(13) |
Oct
(49) |
Nov
(1) |
Dec
(8) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(12) |
Feb
(42) |
Mar
(61) |
Apr
(36) |
May
(20) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(7) |
| 2004 |
Jan
(29) |
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(5) |
| 2005 |
Jan
(12) |
Feb
(5) |
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
(15) |
Nov
(89) |
Dec
(85) |
| 2006 |
Jan
(17) |
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <gc...@us...> - 2003-03-11 18:57:29
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests In directory sc8-pr-cvs1:/tmp/cvs-serv11402/DotNetMock.Framework.Tests Log Message: Directory /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests added to the repository |
|
From: <gc...@us...> - 2003-03-11 18:57:14
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework In directory sc8-pr-cvs1:/tmp/cvs-serv11274/DotNetMock.Framework Log Message: Directory /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework added to the repository |
|
From: <gc...@us...> - 2003-02-26 17:23:40
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/data
In directory sc8-pr-cvs1:/tmp/cvs-serv10457/DotNetMock.Tests/data
Added Files:
MockDataParameterCollectionTests.cs MockDbConnectionTests.cs
Log Message:
--- NEW FILE: MockDataParameterCollectionTests.cs ---
using System;
using NUnit.Framework;
using DotNetMock;
using DotNetMock.Data;
using System.Data;
namespace DotNetMock.Tests.Data
{
[TestFixture]
public class MockDataParameterCollectionTests
{
private MockDataParameterCollection _mockDataParameterCollection = null;
[SetUp]
public void Init()
{
_mockDataParameterCollection = new MockDataParameterCollection();
}
[TearDown]
public void Destroy()
{
_mockDataParameterCollection = null;
}
[Test]
public void AddOneParameter()
{
MockDataParameter mockDP1 = new MockDataParameter("@inpID", "123456");
_mockDataParameterCollection.AddExpected(mockDP1);
_mockDataParameterCollection.Add(mockDP1);
_mockDataParameterCollection.Verify();
}
[Test]
public void AddMultipleParameters()
{
MockDataParameter mockDP1 = new MockDataParameter("@inpID", "123456");
MockDataParameter mockDP2 = new MockDataParameter("@password", "mock");
_mockDataParameterCollection.AddExpected(mockDP1);
_mockDataParameterCollection.AddExpected(mockDP2);
_mockDataParameterCollection.Add(new MockDataParameter("@inpID", "123456"));
_mockDataParameterCollection.Add(new MockDataParameter("@password", "mock"));
_mockDataParameterCollection.Verify();
}
[Test]
public void AddNewParameterStringValue()
{
_mockDataParameterCollection.Add("@inpID", "123456");
MockDataParameter mockDP = new MockDataParameter("@inpID", "123456");
_mockDataParameterCollection.AddExpected(mockDP);
_mockDataParameterCollection.Verify();
}
[Test]
public void AddNewParameterNameType()
{
_mockDataParameterCollection.Add("@inpID", DbType.String);
MockDataParameter mockDP = new MockDataParameter("@inpID", DbType.String);
_mockDataParameterCollection.AddExpected(mockDP);
_mockDataParameterCollection.Verify();
}
[Test]
public void ValidContains()
{
_mockDataParameterCollection.Add("@inpID", "123456");
NUnit.Framework.Assertion.Assert(_mockDataParameterCollection.Contains("@inpID"));
_mockDataParameterCollection.Add("@inpPassword", "password");
NUnit.Framework.Assertion.Assert(_mockDataParameterCollection.Contains("@inpID"));
NUnit.Framework.Assertion.Assert(_mockDataParameterCollection.Contains("@inpPassword"));
}
[Test]
public void InValidContains()
{
IDataParameter mockDP = _mockDataParameterCollection.Add("@inpID", "123456");
NUnit.Framework.Assertion.Assert(!_mockDataParameterCollection.Contains("@inpPassword"));
}
[Test]
public void ValidRemoveAt()
{
_mockDataParameterCollection.Add("@inpID", "123456");
_mockDataParameterCollection.Add("@inpPassword", "password");
NUnit.Framework.Assertion.Assert(_mockDataParameterCollection.Contains("@inpID"));
NUnit.Framework.Assertion.Assert(_mockDataParameterCollection.Contains("@inpPassword"));
_mockDataParameterCollection.RemoveAt("@inpID");
NUnit.Framework.Assertion.Assert(!_mockDataParameterCollection.Contains("@inpID"));
NUnit.Framework.Assertion.Assert(_mockDataParameterCollection.Contains("@inpPassword"));
}
[Test]
[ExpectedException(typeof(ApplicationException))]
public void InValidRemoveAt()
{
IDataParameter mockDP = _mockDataParameterCollection.Add("@inpID", "123456");
_mockDataParameterCollection.RemoveAt("@inpPassword");
}
[Test]
public void IndexOf()
{
_mockDataParameterCollection.Add("@inpID", "123456");
_mockDataParameterCollection.Add("@inpPassword", "password");
_mockDataParameterCollection.Add("@inpThird", "third");
NUnit.Framework.Assertion.AssertEquals("Indexes do not equal", 1, _mockDataParameterCollection.IndexOf("@inpPassword"));
NUnit.Framework.Assertion.AssertEquals("Indexes do not equal", 0, _mockDataParameterCollection.IndexOf("@inpID"));
}
[Test]
[ExpectedException(typeof(ApplicationException))]
public void InValidIndexOf()
{
IDataParameter mockDP = _mockDataParameterCollection.Add("@inpID", "123456");
IDataParameter mockDP1 = _mockDataParameterCollection.Add("@inpPassword", "password");
IDataParameter mockDP2 = _mockDataParameterCollection.Add("@inpThird", "third");
NUnit.Framework.Assertion.AssertEquals("Index not found", 4, _mockDataParameterCollection.IndexOf("@inpFake"));
}
[Test]
public void ValidIndexer()
{
MockDataParameter mockDP = new MockDataParameter("@inpID", "123456");
_mockDataParameterCollection.Add(mockDP);
NUnit.Framework.Assertion.AssertEquals("Parameters not equal", "@inpID", _mockDataParameterCollection["@inpID"]);
}
[Test]
[ExpectedException(typeof(ApplicationException))]
public void InValidIndexer()
{
MockDataParameter mockDP = new MockDataParameter("@inpID", "654321");
_mockDataParameterCollection.Add(mockDP);
NUnit.Framework.Assertion.AssertEquals("Parameters not equal", mockDP, _mockDataParameterCollection["@inpPadssword"]);
}
[Test]
[ExpectedException(typeof(NotImplementedException))]
public void InValidInsert()
{
_mockDataParameterCollection.Insert(3, "fake");
}
[Test]
[ExpectedException(typeof(NotImplementedException))]
public void InValidIListIndexOf()
{
object badValue = new object();
int index = _mockDataParameterCollection.IndexOf(badValue);
}
[Test]
[ExpectedException(typeof(NotImplementedException))]
public void InValidRemove()
{
object badValue = new object();
_mockDataParameterCollection.Remove(badValue);
}
[Test]
[ExpectedException(typeof(NotImplementedException))]
public void InValidIListContains()
{
object badValue = new object();
_mockDataParameterCollection.Contains(badValue);
}
}
}
--- NEW FILE: MockDbConnectionTests.cs ---
using System;
using DotNetMock.Data;
using NUnit.Framework;
namespace DotNetMock.Tests.Data
{
[TestFixture]
public class MockDbConnectionTests
{
private MockDbConnection _mockConnection = null;
[SetUp]
public void Init()
{
_mockConnection = new MockDbConnection();
}
[TearDown]
public void Destroy()
{
_mockConnection.Dispose();
_mockConnection = null;
}
[Test]
public void CloseCalls()
{
_mockConnection.SetExpectedCloseCalls(3);
_mockConnection.Close();
_mockConnection.Close();
_mockConnection.Close();
_mockConnection.Verify();
}
[Test]
[ExpectedException(typeof(AssertionException))]
public void InvalidCloseCalls()
{
_mockConnection.SetExpectedCloseCalls(1);
_mockConnection.Close();
_mockConnection.Close();
_mockConnection.Verify();
}
[Test]
public void ConnectionString()
{
_mockConnection.SetExpectedConnectionString("DSN=localhost");
_mockConnection.ConnectionString = "DSN=localhost";
_mockConnection.Verify();
}
[Test]
[ExpectedException(typeof(AssertionException))]
public void InvalidConnectionString()
{
_mockConnection.SetExpectedConnectionString("DSN=localhost");
_mockConnection.ConnectionString = "DSN=";
_mockConnection.Verify();
}
}
}
|
|
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();
}
}
}
|
|
From: <gc...@us...> - 2003-02-26 17:21:30
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Data
In directory sc8-pr-cvs1:/tmp/cvs-serv8930/DotNetMock/Data
Added Files:
MockDataParameterCollection.cs
Log Message:
Added MockDataParameterCollection
--- NEW FILE: MockDataParameterCollection.cs ---
using System;
using System.Data;
using System.Collections;
using System.Globalization;
namespace DotNetMock.Data
{
/// <summary>
/// This is a Mock Object that implements the IDataParameterCollection interface. It holds a collection of IDataParamter objects.
/// </summary>
public class MockDataParameterCollection : MockObject, IDataParameterCollection
{
/// <summary>
/// Internal collection of parameters.
/// </summary>
private ExpectationArrayList _parameterCollection = new ExpectationArrayList("MockDataParameterCollection.Tests");
/// <summary>
/// Flag indicating read-only status.
/// </summary>
private bool _isReadOnly = false;
/// <summary>
/// Flag indicating fixed-size status.
/// </summary>
private bool _isFixedSize = false;
/// <summary>
/// Default constructor
/// </summary>
public MockDataParameterCollection()
{
}
/// <summary>
/// Adds expected paramter to the expected collection
/// </summary>
/// <param name="parameter">Parameter to add</param>
public void AddExpected(IDataParameter parameter)
{
_parameterCollection.AddExpected(parameter.ParameterName);
}
#region Implementation of IDataParameterCollection
/// <summary>
/// Removes a parameter from the Actual collection
/// </summary>
/// <param name="parameterName">Name of parameter to remove</param>
public void RemoveAt(string parameterName)
{
IList actual = _parameterCollection.ActualCollection;
if (!this.Contains(parameterName) )
{
throw new ApplicationException("Parameter by that name cannot be found.");
}
for (int i = 0; i < actual.Count; i++)
{
if (actual[i].Equals(parameterName))
{
this.RemoveAt(i);
}
}
}
/// <summary>
/// Verifies if the collection contains a parameter with the given name
/// </summary>
/// <param name="parameterName">Name of parameter to check</param>
/// <returns>True/False</returns>
public bool Contains(string parameterName)
{
bool result = false;
IList actual = _parameterCollection.ActualCollection;
for (int i = 0; i < actual.Count; i++)
{
if (actual[i].Equals(parameterName))
{
result = true;
}
}
return result;
}
/// <summary>
/// Returns the index of the parameter with the given name
/// </summary>
/// <param name="parameterName">Name of the parameter</param>
/// <returns>Zero based index of the parameter</returns>
public int IndexOf(string parameterName)
{
if (!this.Contains(parameterName) )
{
throw new ApplicationException("Parameter by that name cannot be found.");
}
int index = 0;
IList actual = _parameterCollection.ActualCollection;
for (int i = 0; i < actual.Count; i++)
{
if (actual[i].Equals(parameterName))
{
index = i;
}
}
return index;
}
/// <summary>
/// Property: Provides index-based access to the parameter collection
/// </summary>
public object this[string parameterName]
{
get
{
IList actual = _parameterCollection.ActualCollection;
return actual[IndexOf(parameterName)];
}
set
{
IList actual = _parameterCollection.ActualCollection;
actual[IndexOf(parameterName)] = value;
}
}
#endregion
#region Implementation of IList
/// <summary>
/// Removes the parameter at the given index
/// </summary>
/// <param name="index">Index to remove</param>
public void RemoveAt(int index)
{
IList actual = _parameterCollection.ActualCollection;
actual.RemoveAt(index);
}
/// <summary>
/// Inserts a parameter at the given index. Currently *Not Implemented*
/// </summary>
/// <param name="index">Index to use</param>
/// <param name="value">Parameter to use</param>
public void Insert(int index, object value)
{
throw new NotImplementedException("Not implemented. Please use one of the Add() methods instead");
}
/// <summary>
/// Removes parameter. Currently *Not Implemented*. Please use RemoveAt() instead.
/// </summary>
/// <param name="value">Parameter to remove</param>
public void Remove(object value)
{
throw new NotImplementedException("Not implemented. Please use RemoveAt() instead");
}
/// <summary>
/// Verifies object is contained in the collection. Currently *Not Implemented*. Please use Contains(string parameterName) instead.
/// </summary>
/// <param name="value">Parameter to check</param>
/// <returns>True/False</returns>
public bool Contains(object value)
{
throw new NotImplementedException("Not implemented. Please use IDataParameterCollection.Contains(string parameterName) instead");
}
/// <summary>
/// Clears Actual Collection
/// </summary>
public void Clear()
{
IList actual = _parameterCollection.ActualCollection;
actual.Clear();
}
/// <summary>
/// Returns index of value. Currently *Not Implemented*. Please use IndexOf(string parameterName) instead.
/// </summary>
/// <param name="value">Value to check</param>
/// <returns>Index of value</returns>
public int IndexOf(object value)
{
throw new NotImplementedException("Not implemented. Please use IDataParameterCollection.IndexOf(string parameterName) instead");
}
/// <summary>
/// Adds a new MockDataParameter to the collection, with the given name and value.
/// </summary>
/// <param name="parameterName">Parameter name to use.</param>
/// <param name="parameterValue">Parameter value to use.</param>
/// <returns>Parameter added</returns>
public IDataParameter Add(string parameterName, string parameterValue)
{
Add(parameterName);
return null;
}
/// <summary>
/// Adds IDataParameter to the collection.
/// </summary>
/// <param name="value">Parameter to add.</param>
/// <returns>Parameter added</returns>
public IDataParameter Add(IDataParameter value)
{
Add(value.ParameterName);
return null;
}
/// <summary>
/// Adds a new MockDataParameter to the collection, with the given name and type.
/// </summary>
/// <param name="parameterName">Parameter name to use.</param>
/// <param name="type">Type of new parameter</param>
/// <returns>Parameter added</returns>
public IDataParameter Add(string parameterName, DbType type)
{
Add(parameterName);
return null;
}
/// <summary>
/// Adds value to the collection, as a IDataParameter.
/// </summary>
/// <param name="value">Value to add</param>
/// <returns>0</returns>
public int Add(object value)
{
_parameterCollection.AddActual(value);
return 0;
}
/// <summary>
/// Gets value indicating if the collection is read-only.
/// </summary>
public bool IsReadOnly
{
get
{
return _isReadOnly;
}
set
{
_isReadOnly = value;
}
}
/// <summary>
/// Provides zero-based index access to the collection.
/// </summary>
public object this[int index]
{
get
{
IList actual = _parameterCollection.ActualCollection;
return (object)actual[index];
}
set
{
IList actual = _parameterCollection.ActualCollection;
actual[index] = (IDataParameter)value;
}
}
/// <summary>
/// Gets value indicating if the collection is fixed-size or not.
/// </summary>
public bool IsFixedSize
{
get
{
return _isFixedSize;
}
set
{
_isFixedSize = value;
}
}
#endregion
#region Implementation of ICollection
/// <summary>
/// Copies section of collection to given array. Currently *Not Implemented*
/// </summary>
/// <param name="array">Array to use</param>
/// <param name="index">Collection index to start at</param>
public void CopyTo(System.Array array, int index)
{
throw new NotImplementedException("Not Implemented.");
}
/// <summary>
/// Gets count of collection
/// </summary>
public int Count
{
get
{
IList actual = _parameterCollection.ActualCollection;
return actual.Count;
}
}
// TODO: Implement thread-safe collection
/// <summary>
/// Gets value indicating if the collection is synchronized for thread-safe use.
/// </summary>
public bool IsSynchronized
{
get
{
throw new NotImplementedException("Not implemented.");
}
}
// TODO: Implement thread-safe collection
/// <summary>
/// Returns synchronized root of the collection.
/// </summary>
public object SyncRoot
{
get
{
throw new NotImplementedException("Not implemented.");
}
}
#endregion
#region Implementation of IEnumerable
/// <summary>
/// Gets IEnumerator that can enumerate over the collection
/// </summary>
/// <returns></returns>
public System.Collections.IEnumerator GetEnumerator()
{
IList actual = _parameterCollection.ActualCollection;
return actual.GetEnumerator();
}
#endregion
}
}
|
|
From: <gc...@us...> - 2003-02-26 17:18:27
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock
In directory sc8-pr-cvs1:/tmp/cvs-serv7217/DotNetMock
Added Files:
ExpectationBool.cs ExpectationType.cs NullObject.cs
Log Message:
--- NEW FILE: ExpectationBool.cs ---
using System;
namespace DotNetMock
{
/// <summary>
/// Expectation Bool implementation. Extends <c>AbstractExpectation</c>
/// </summary>
/// <remarks/>
public class ExpectationBool : AbstractExpectation
{
private bool _actualBool = false;
private bool _expectedBool = false;
/// <summary>
/// Default Constructor
/// </summary>
/// <param name="name">Name of this Expectation</param>
public ExpectationBool(string name) : base(name) {}
/// <summary>
/// Clears actual value
/// </summary>
public override void ClearActual()
{
this._actualBool = false;
}
/// <summary>
/// Clear expected value
/// </summary>
public override void ClearExpected()
{
this._expectedBool = false;
}
/// <summary>
/// Verifies object
/// </summary>
public override void Verify()
{
if (this.HasExpectations)
{
NUnit.Framework.Assertion.AssertEquals("Bool values not equal for " + this.name, this._expectedBool, this._actualBool);
}
}
/// <summary>
/// Gets/Sets actual boolean value
/// </summary>
public bool Actual
{
get { return _actualBool; }
set { _actualBool = value;}
}
/// <summary>
/// Gets/Sets expected boolean value
/// </summary>
public bool Expected
{
get { return _expectedBool; }
set {
_expectedBool = value;
this.HasExpectations = true;
}
}
}
}
--- NEW FILE: ExpectationType.cs ---
using System;
namespace DotNetMock
{
/// <summary>
/// Expectation Type implementation. Extends <c>AbstractExpectation</c>
/// </summary>
/// <remarks/>
public class ExpectationType : AbstractExpectation
{
private Type _actualType = null;
private Type _expectedType = null;
/// <summary>
///
/// </summary>
/// <param name="name"></param>
public ExpectationType(string name) : base(name)
{
ClearActual();
}
/// <summary>
/// Clears Actual value.
/// </summary>
public override void ClearActual()
{
this._actualType = null;
}
/// <summary>
/// Clears Expected value.
/// </summary>
public override void ClearExpected()
{
this._expectedType = null;
}
/// <summary>
/// Gets/Sets Actual values.
/// </summary>
public Type Actual
{
get
{
return this._actualType;
}
set
{
this._actualType = (Type)value;
if (ShouldCheckImmediate)
{
Verify();
}
}
}
/// <summary>
/// Gets/Sets Expected value.
/// </summary>
public Type Expected
{
get
{
return this._expectedType;
}
set
{
this._expectedType = (Type)value;
this.HasExpectations = true;
}
}
/// <summary>
/// Verifies object.
/// </summary>
public override void Verify()
{
if (this.HasExpectations)
{
NUnit.Framework.Assertion.AssertEquals("Types do not equal for object " + this.name, this._expectedType, this._actualType);
}
}
}
}
--- NEW FILE: NullObject.cs ---
namespace DotNetMock
{
using System;
/// <summary>
/// This represents a Null Object.
/// </summary>
/// <remarks/>
public class NullObject
{
private string _name;
public NullObject() {
_name = "null";
}
public NullObject(string name) {
_name = name;
}
/// <summary>
/// Overrides Object.ToString().
/// </summary>
/// <returns>Object Name.</returns>
public override string ToString()
{
return _name;
}
/// <summary>
/// Determines if the given object is Null object.
/// </summary>
/// <param name="other">Object to compare.</param>
/// <returns>True/False.</returns>
public override bool Equals(Object other)
{
return (other is NullObject);
}
/// <summary>
/// Returns unique hash code for the object.
/// </summary>
/// <returns>Objects HashCode.</returns>
public override int GetHashCode()
{
return _name.GetHashCode();
}
}
}
|
|
From: <gc...@us...> - 2003-02-26 17:16:05
|
Update of /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject/Templates/1033 In directory sc8-pr-cvs1:/tmp/cvs-serv5269/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject/Templates/1033 Added Files: NewMockObjectFile.cs Templates.inf Log Message: Added VS.NET template files for both new Mock Objects & NUnit Test Fixtures --- NEW FILE: NewMockObjectFile.cs --- using System; using DotNetMock; namespace [!output SAFE_NAMESPACE_NAME] { /// <summary> /// TODO: Describe the Mock Object here. Include what object or interface it is mocking. /// </summary> public class [!output SAFE_CLASS_NAME] : MockObject { public [!output SAFE_CLASS_NAME]() { this.name = "[!output SAFE_CLASS_NAME]"; } } } --- NEW FILE: Templates.inf --- NewMockObjectFile.cs |
|
From: <gc...@us...> - 2003-02-26 17:16:01
|
Update of /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject/Scripts/1033 In directory sc8-pr-cvs1:/tmp/cvs-serv5269/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject/Scripts/1033 Added Files: default.js Log Message: Added VS.NET template files for both new Mock Objects & NUnit Test Fixtures --- NEW FILE: default.js --- // (c) 2001 Microsoft Corporation function OnFinish(selProj, selObj) { var oldSuppressUIValue = true; try { var strTarget = wizard.FindSymbol("ITEM_NAME"); var strClassName = strTarget.split("."); var bValid = wizard.ValidateCLRIdentifier(strClassName[0]); if (!bValid) return VS_E_WIZARDBACKBUTTONPRESS; oldSuppressUIValue = dte.SuppressUI; var strProjectName = wizard.FindSymbol("PROJECT_NAME"); var strSafeProjectName = CreateSafeName(strProjectName); wizard.AddSymbol("SAFE_PROJECT_NAME", strSafeProjectName); SetTargetFullPath(selObj); var strProjectPath = wizard.FindSymbol("TARGET_FULLPATH"); var strTemplatePath = wizard.FindSymbol("TEMPLATES_PATH"); var strTpl = ""; var strName = ""; var InfFile = CreateInfFile(); AddReferencesForClass(selProj); AddFilesToCSharpProject(selObj, strProjectName, strProjectPath, InfFile, true); } catch(e) { if( e.description.length > 0 ) SetErrorInfo(e); return e.number; } finally { dte.SuppressUI = oldSuppressUIValue; if( InfFile ) InfFile.Delete(); } } function SetFileProperties(oFileItem, strFileName) { } |
|
From: <gc...@us...> - 2003-02-26 17:16:00
|
Update of /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/CSharpProjectItems In directory sc8-pr-cvs1:/tmp/cvs-serv5269/VisualStudioTemplates/CSharpProjectItems Added Files: CSharpAddMockObject.vsz CSharpAddNUnitTest.vsz Log Message: Added VS.NET template files for both new Mock Objects & NUnit Test Fixtures --- NEW FILE: CSharpAddMockObject.vsz --- VSWIZARD 7.0 Wizard=VsWizard.VsWizardEngine Param="WIZARD_NAME = CSharpAddMockObject" Param="WIZARD_UI = FALSE" Param="PROJECT_TYPE = CSPROJ" --- NEW FILE: CSharpAddNUnitTest.vsz --- VSWIZARD 7.0 Wizard=VsWizard.VsWizardEngine Param="WIZARD_NAME = CSHarpAddNUnitTest" Param="WIZARD_UI = FALSE" Param="PROJECT_TYPE = CSPROJ" |
|
From: <gc...@us...> - 2003-02-26 17:15:03
|
Update of /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject/Templates/1033 In directory sc8-pr-cvs1:/tmp/cvs-serv4927/1033 Log Message: Directory /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject/Templates/1033 added to the repository |
|
From: <gc...@us...> - 2003-02-26 17:14:29
|
Update of /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject/Scripts/1033 In directory sc8-pr-cvs1:/tmp/cvs-serv4609/1033 Log Message: Directory /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject/Scripts/1033 added to the repository |
|
From: <gc...@us...> - 2003-02-26 17:14:19
|
Update of /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject/Templates In directory sc8-pr-cvs1:/tmp/cvs-serv4507/Templates Log Message: Directory /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject/Templates added to the repository |
|
From: <gc...@us...> - 2003-02-26 17:14:15
|
Update of /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject/Scripts In directory sc8-pr-cvs1:/tmp/cvs-serv4462/Scripts Log Message: Directory /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject/Scripts added to the repository |
|
From: <gc...@us...> - 2003-02-26 17:13:11
|
Update of /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddNUnitTest In directory sc8-pr-cvs1:/tmp/cvs-serv3857/CSharpAddNUnitTest Log Message: Directory /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddNUnitTest added to the repository |
|
From: <gc...@us...> - 2003-02-26 17:13:06
|
Update of /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject In directory sc8-pr-cvs1:/tmp/cvs-serv3785/CSharpAddMockObject Log Message: Directory /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards/CSharpAddMockObject added to the repository |
|
From: <gc...@us...> - 2003-02-26 17:12:40
|
Update of /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards In directory sc8-pr-cvs1:/tmp/cvs-serv3460/VC#Wizards Log Message: Directory /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/VC#Wizards added to the repository |
|
From: <gc...@us...> - 2003-02-26 17:12:30
|
Update of /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/CSharpProjectItems In directory sc8-pr-cvs1:/tmp/cvs-serv3394/CSharpProjectItems Log Message: Directory /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates/CSharpProjectItems added to the repository |
|
From: <gc...@us...> - 2003-02-26 17:12:17
|
Update of /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates In directory sc8-pr-cvs1:/tmp/cvs-serv3246/VisualStudioTemplates Log Message: Directory /cvsroot/dotnetmock/dotnetmock/VisualStudioTemplates added to the repository |
|
From: <gc...@us...> - 2003-02-13 17:53:22
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Examples/Security
In directory sc8-pr-cvs1:/tmp/cvs-serv27506/DotNetMock.Examples/Security
Added Files:
SensitiveClass.cs SensitiveClassTests.cs
Log Message:
Added Security example to the Examples project
--- NEW FILE: SensitiveClass.cs ---
using System;
using System.Threading;
using System.Security;
using System.Security.Permissions;
using System.Security.Principal;
namespace DotNetMock.Examples.Security
{
/// <summary>
/// This is a "Sensitive" class that will demonstrate how to use the MockIPrincipal
/// class for 3 type of security checks: Manually, Imperatively, and Declaratively
/// </summary>
public class SensitiveClass
{
public SensitiveClass()
{
}
public bool CanRunManualCEOCheck()
{
bool allowed = false;
IPrincipal currentPrincipal = Thread.CurrentPrincipal;
if ( currentPrincipal.Identity.IsAuthenticated )
{
if ( currentPrincipal.IsInRole( "CEO" ) )
{
// Inside of this statment, we would run some code that requires the CEO role.
// For this example all we are going to do is verify the fact that the caller has
// the CEO role
allowed = true;
}
}
return allowed;
}
public bool CanRunImperativeCEOCheck()
{
bool allowed = false;
PrincipalPermission CEOPermission = new PrincipalPermission(null, "CEO");
try
{
CEOPermission.Demand();
allowed = true;
}
catch (SecurityException ex)
{
}
return allowed;
}
[PrincipalPermission (SecurityAction.Demand, Role="CEO")]
public bool CanRunDeclarativeCEOCheck()
{
return true;
}
}
}
--- NEW FILE: SensitiveClassTests.cs ---
using System;
using System.Security;
using System.Threading;
using NUnit.Framework;
using DotNetMock.Security.Principal;
namespace DotNetMock.Examples.Security
{
[TestFixture]
public class SensitiveClassTests
{
private SensitiveClass sensitiveClass = null;
private MockIIdentity mockIdentity = null;
private MockIPrincipal mockPrincipal = null;
[SetUp]
public void Init()
{
sensitiveClass = new SensitiveClass();
mockIdentity = new MockIIdentity();
mockPrincipal = new MockIPrincipal();
mockPrincipal.SetExpectedIdentity( mockIdentity );
Thread.CurrentPrincipal = mockPrincipal;
}
[TearDown]
public void Destroy()
{
sensitiveClass = null;
mockIdentity = null;
mockPrincipal = null;
}
[Test]
public void ManualCEOCheck()
{
mockIdentity.SetExpectedAuthenticationType( "NTLM" );
mockIdentity.SetExpectedIsAuthenticated( true );
mockIdentity.SetExpectedName( "Mr. CEO" );
mockPrincipal.SetExpectedIsInRoleCount(1);
mockPrincipal.AddExpectedRole( "CEO" );
Assertion.Assert( "Cannot run Manual CEO Check!", sensitiveClass.CanRunManualCEOCheck() );
verifyMocks();
}
[Test]
public void CannotRunManualCEOCheck()
{
mockIdentity.SetExpectedAuthenticationType( "NTLM" );
mockIdentity.SetExpectedIsAuthenticated( true );
mockIdentity.SetExpectedName( "Mr. Employee" );
mockPrincipal.SetExpectedIsInRoleCount(1);
mockPrincipal.AddExpectedRole( "Employee" );
Assertion.Assert( "Can run Manual CEO Check!", !sensitiveClass.CanRunManualCEOCheck() );
verifyMocks();
}
[Test]
public void NotAuthenticatedForCEOCheck()
{
mockIdentity.SetExpectedAuthenticationType( "NTLM" );
mockIdentity.SetExpectedIsAuthenticated( false );
mockIdentity.SetExpectedName( "Mr. Employee" );
mockPrincipal.SetExpectedIsInRoleCount(0);
Assertion.Assert( "Authenticated!", !sensitiveClass.CanRunManualCEOCheck() );
verifyMocks();
}
[Test]
public void ImperativeCEOCheck()
{
mockIdentity.SetExpectedAuthenticationType( "NTLM" );
mockIdentity.SetExpectedIsAuthenticated( true );
mockIdentity.SetExpectedName( "Mr. CEO" );
mockPrincipal.SetExpectedIsInRoleCount(1);
mockPrincipal.AddExpectedRole( "CEO" );
Assertion.Assert( "Cannot run Imperative CEO Check!", sensitiveClass.CanRunImperativeCEOCheck() );
verifyMocks();
}
[Test]
public void CannotRunImperativeCEOCheck()
{
mockIdentity.SetExpectedAuthenticationType( "NTLM" );
mockIdentity.SetExpectedIsAuthenticated( true );
mockIdentity.SetExpectedName( "Mr. Employee" );
mockPrincipal.SetExpectedIsInRoleCount(1);
mockPrincipal.AddExpectedRole( "Employee" );
Assertion.Assert( "Can run Imperative CEO Check!", !sensitiveClass.CanRunImperativeCEOCheck() );
verifyMocks();
}
[Test]
public void NotAuthenticatedForImperativeCEOCheck()
{
mockIdentity.SetExpectedAuthenticationType( "NTLM" );
mockIdentity.SetExpectedIsAuthenticated( false );
mockIdentity.SetExpectedName( "Mr. Employee" );
mockPrincipal.SetExpectedIsInRoleCount(0);
Assertion.Assert( "Authenticated!", !sensitiveClass.CanRunImperativeCEOCheck() );
verifyMocks();
}
[Test]
public void DeclarativeCEOCheck()
{
mockIdentity.SetExpectedAuthenticationType( "NTLM" );
mockIdentity.SetExpectedIsAuthenticated( true );
mockIdentity.SetExpectedName( "Mr. CEO" );
mockPrincipal.SetExpectedIsInRoleCount(1);
mockPrincipal.AddExpectedRole( "CEO" );
Assertion.Assert( "Cannot run Declarative CEO Check!", sensitiveClass.CanRunDeclarativeCEOCheck() );
verifyMocks();
}
[Test]
[ExpectedException(typeof(SecurityException))]
public void CannotRunDeclarativeCEOCheck()
{
mockIdentity.SetExpectedAuthenticationType( "NTLM" );
mockIdentity.SetExpectedIsAuthenticated( true );
mockIdentity.SetExpectedName( "Mr. Employee" );
mockPrincipal.SetExpectedIsInRoleCount(1);
mockPrincipal.AddExpectedRole( "Employee" );
try
{
sensitiveClass.CanRunDeclarativeCEOCheck();
}
finally
{
verifyMocks();
}
}
[Test]
[ExpectedException(typeof(SecurityException))]
public void NotAuthenticatedForDeclarativeCEOCheck()
{
mockIdentity.SetExpectedAuthenticationType( "NTLM" );
mockIdentity.SetExpectedIsAuthenticated( false );
mockIdentity.SetExpectedName( "Mr. Employee" );
mockPrincipal.SetExpectedIsInRoleCount(0);
try
{
sensitiveClass.CanRunDeclarativeCEOCheck();
}
finally
{
verifyMocks();
}
}
private void verifyMocks()
{
mockIdentity.Verify();
mockPrincipal.Verify();
}
}
}
|
|
From: <gc...@us...> - 2003-02-13 17:52:50
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Examples/Security In directory sc8-pr-cvs1:/tmp/cvs-serv27362/Security Log Message: Directory /cvsroot/dotnetmock/dotnetmock/DotNetMock.Examples/Security added to the repository |
|
From: <gc...@us...> - 2003-02-13 16:21:39
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Security/Principal
In directory sc8-pr-cvs1:/tmp/cvs-serv17685/DotNetMock/Security/Principal
Modified Files:
MockIIdentity.cs MockIPrincipal.cs
Log Message:
Added XML Comments to MockIIDentity & MockIPrincipal
Index: MockIIdentity.cs
===================================================================
RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Security/Principal/MockIIdentity.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MockIIdentity.cs 13 Feb 2003 03:33:47 -0000 1.1
--- MockIIdentity.cs 13 Feb 2003 16:21:32 -0000 1.2
***************
*** 5,32 ****
namespace DotNetMock.Security.Principal
{
public class MockIIdentity : MockObject, IIdentity
{
private string _expectedAuthType = "";
private string _expectedName = "";
!
private bool _expectedIsAuth = false;
!
public MockIIdentity()
{
this.name = "MockIdentity";
}
public void SetExpectedAuthenticationType( string authType )
{
_expectedAuthType = authType;
}
public void SetExpectedIsAuthenticated( bool isAuth )
{
_expectedIsAuth = isAuth;
}
public void SetExpectedName( string name )
{
_expectedName = name;
}
#region Implementation of IIdentity
public bool IsAuthenticated
{
--- 5,63 ----
namespace DotNetMock.Security.Principal
{
+ /// <summary>
+ /// MockObject implementing the IIdentity interface. Since the IIdentity interface only includes getters,
+ /// this MockObject does not do much.
+ /// </summary>
public class MockIIdentity : MockObject, IIdentity
{
+ /// <summary>
+ /// The expected AuthenticationType
+ /// </summary>
private string _expectedAuthType = "";
+ /// <summary>
+ /// The expected Name
+ /// </summary>
private string _expectedName = "";
! /// <summary>
! /// The expected value for IsAuthenticated
! /// </summary>
private bool _expectedIsAuth = false;
! /// <summary>
! /// Default Constructor
! /// </summary>
public MockIIdentity()
{
this.name = "MockIdentity";
}
+ #region Mock Methods
+ /// <summary>
+ /// Sets the expected AuthenticationType value to return
+ /// </summary>
+ /// <param name="authType">Authentication Type to return</param>
public void SetExpectedAuthenticationType( string authType )
{
_expectedAuthType = authType;
}
+ /// <summary>
+ /// Sets the expected IsAuthenticated value to return
+ /// </summary>
+ /// <param name="isAuth">IsAuthenticated value to return</param>
public void SetExpectedIsAuthenticated( bool isAuth )
{
_expectedIsAuth = isAuth;
}
+ /// <summary>
+ /// Sets the expected Name value to return
+ /// </summary>
+ /// <param name="name">Name value to return</param>
public void SetExpectedName( string name )
{
_expectedName = name;
}
+ #endregion
#region Implementation of IIdentity
+ /// <summary>
+ /// Returns true/false if the current Identity is Authenticated or not
+ /// </summary>
public bool IsAuthenticated
{
***************
*** 36,40 ****
}
}
!
public string Name
{
--- 67,73 ----
}
}
! /// <summary>
! /// Returns the name of the current Identity
! /// </summary>
public string Name
{
***************
*** 44,48 ****
}
}
!
public string AuthenticationType
{
--- 77,83 ----
}
}
! /// <summary>
! /// Returns the current Authentication Type
! /// </summary>
public string AuthenticationType
{
Index: MockIPrincipal.cs
===================================================================
RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Security/Principal/MockIPrincipal.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MockIPrincipal.cs 13 Feb 2003 02:56:38 -0000 1.1
--- MockIPrincipal.cs 13 Feb 2003 16:21:33 -0000 1.2
***************
*** 6,16 ****
namespace DotNetMock.Security.Principal
{
public class MockIPrincipal : MockObject, IPrincipal
{
private IIdentity _expectedIdentity = null;
private ExpectationCounter _isInRoleCalls = new ExpectationCounter("MockIPrincipal.IsIsRoleCalls");
!
private ArrayList _roles = null;
!
public MockIPrincipal()
{
--- 6,29 ----
namespace DotNetMock.Security.Principal
{
+ /// <summary>
+ /// Mock Object to implement the IPrincipal interface
+ /// </summary>
public class MockIPrincipal : MockObject, IPrincipal
{
+ /// <summary>
+ /// Current Identity associated with this Principal
+ /// </summary>
private IIdentity _expectedIdentity = null;
+ /// <summary>
+ /// Expected number of IsInRole() calls
+ /// </summary>
private ExpectationCounter _isInRoleCalls = new ExpectationCounter("MockIPrincipal.IsIsRoleCalls");
! /// <summary>
! /// Lists of roles the current Principal belongs to
! /// </summary>
private ArrayList _roles = null;
! /// <summary>
! /// Default Constructor
! /// </summary>
public MockIPrincipal()
{
***************
*** 19,34 ****
--- 32,63 ----
}
#region MockMethods
+ /// <summary>
+ /// Sets the expected value of Identity to return
+ /// </summary>
+ /// <param name="identity">Identity for current Principal</param>
public void SetExpectedIdentity( IIdentity identity )
{
_expectedIdentity = identity;
}
+ /// <summary>
+ /// Sets the number of calls to IsInRole()
+ /// </summary>
+ /// <param name="count">expected number of calls to IsInRol()</param>
public void SetExpectedIsInRoleCount( int count )
{
_isInRoleCalls.Expected = count;
}
+ /// <summary>
+ /// Adds the given role to the list of roles this Principal belongs to
+ /// </summary>
+ /// <param name="role">role to add</param>
public void AddExpectedRole( string role )
{
_roles.Add( role );
}
+ /// <summary>
+ /// Adds the given roles to the list of roles this Principal belongs to
+ /// </summary>
+ /// <param name="roles"></param>
public void AddExpectedRoles( string[] roles )
{
***************
*** 40,43 ****
--- 69,77 ----
#endregion
#region Implementation of IPrincipal
+ /// <summary>
+ /// Returns true/false if the current principal belongs to the given role
+ /// </summary>
+ /// <param name="roleToSearch">Role to check for</param>
+ /// <returns>True/False</returns>
public bool IsInRole(string roleToSearch)
{
***************
*** 53,57 ****
return found;
}
!
public System.Security.Principal.IIdentity Identity
{
--- 87,93 ----
return found;
}
! /// <summary>
! /// Returns the current Identity associated with this Principal
! /// </summary>
public System.Security.Principal.IIdentity Identity
{
|
|
From: <gc...@us...> - 2003-02-13 03:33:50
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Security/Principal
In directory sc8-pr-cvs1:/tmp/cvs-serv16054/DotNetMock.Tests/Security/Principal
Added Files:
MockIIdentityTests.cs
Log Message:
Added MockIIdentity implementation
--- 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 );
}
}
}
|
|
From: <gc...@us...> - 2003-02-13 03:33:50
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Security/Principal
In directory sc8-pr-cvs1:/tmp/cvs-serv16054/DotNetMock/Security/Principal
Added Files:
MockIIdentity.cs
Log Message:
Added MockIIdentity implementation
--- NEW FILE: MockIIdentity.cs ---
using System;
using DotNetMock;
using System.Security.Principal;
namespace DotNetMock.Security.Principal
{
public class MockIIdentity : MockObject, IIdentity
{
private string _expectedAuthType = "";
private string _expectedName = "";
private bool _expectedIsAuth = false;
public MockIIdentity()
{
this.name = "MockIdentity";
}
public void SetExpectedAuthenticationType( string authType )
{
_expectedAuthType = authType;
}
public void SetExpectedIsAuthenticated( bool isAuth )
{
_expectedIsAuth = isAuth;
}
public void SetExpectedName( string name )
{
_expectedName = name;
}
#region Implementation of IIdentity
public bool IsAuthenticated
{
get
{
return _expectedIsAuth;
}
}
public string Name
{
get
{
return _expectedName;
}
}
public string AuthenticationType
{
get
{
return _expectedAuthType;
}
}
#endregion
}
}
|
|
From: <gc...@us...> - 2003-02-13 02:56:41
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Security In directory sc8-pr-cvs1:/tmp/cvs-serv4259/DotNetMock.Tests/Security Removed Files: MockIPrincipalTests.cs Log Message: Added System.Security.Principal namespace --- MockIPrincipalTests.cs DELETED --- |
|
From: <gc...@us...> - 2003-02-13 02:56:41
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Security/Principal
In directory sc8-pr-cvs1:/tmp/cvs-serv4259/DotNetMock/Security/Principal
Added Files:
MockIPrincipal.cs
Log Message:
Added System.Security.Principal namespace
--- NEW FILE: MockIPrincipal.cs ---
using System;
using System.Collections;
using System.Security.Principal;
using DotNetMock;
namespace DotNetMock.Security.Principal
{
public class MockIPrincipal : MockObject, IPrincipal
{
private IIdentity _expectedIdentity = null;
private ExpectationCounter _isInRoleCalls = new ExpectationCounter("MockIPrincipal.IsIsRoleCalls");
private ArrayList _roles = null;
public MockIPrincipal()
{
this.name = "MockIPrincipal";
_roles = new ArrayList();
}
#region MockMethods
public void SetExpectedIdentity( IIdentity identity )
{
_expectedIdentity = identity;
}
public void SetExpectedIsInRoleCount( int count )
{
_isInRoleCalls.Expected = count;
}
public void AddExpectedRole( string role )
{
_roles.Add( role );
}
public void AddExpectedRoles( string[] roles )
{
for (int i = 0; i < roles.Length; i++)
{
AddExpectedRole( roles[i] );
}
}
#endregion
#region Implementation of IPrincipal
public bool IsInRole(string roleToSearch)
{
_isInRoleCalls.Inc();
bool found = false;
foreach (string role in _roles)
{
if (role.Equals(roleToSearch))
{
found = true;
}
}
return found;
}
public System.Security.Principal.IIdentity Identity
{
get
{
return _expectedIdentity;
}
}
#endregion
}
}
|