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 20:31:20
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Examples In directory sc8-pr-cvs1:/tmp/cvs-serv20785/DotNetMock.Examples Modified Files: DotNetMock.Examples.csproj Log Message: Index: DotNetMock.Examples.csproj =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock.Examples/DotNetMock.Examples.csproj,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DotNetMock.Examples.csproj 30 Oct 2002 04:46:51 -0000 1.1 --- DotNetMock.Examples.csproj 11 Mar 2003 20:30:45 -0000 1.2 *************** *** 70,74 **** <Reference Name = "System.XML" ! AssemblyName = "System.XML" HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.XML.dll" /> --- 70,74 ---- <Reference Name = "System.XML" ! AssemblyName = "System.Xml" HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.XML.dll" /> *************** *** 83,86 **** --- 83,91 ---- HintPath = "..\lib\nunit.framework.dll" /> + <Reference + Name = "DotNetMock.Framework" + Project = "{514DAB7F-4A05-4343-9BF5-2C3DC60A431D}" + Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}" + /> </References> </Build> *************** *** 109,112 **** --- 114,182 ---- <File RelPath = "Dynamic\WeatherTest.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "MailingList\DatabaseConstants.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "MailingList\IListAction.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "MailingList\MailingList.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "MailingList\MailingListException.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "MailingList\MailingListTests.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "MailingList\MockListAction.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Mainframe\CustomerNumberCollector.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Mainframe\CustomerNumberCollectorTests.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Mainframe\IMainframeConnection.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Mainframe\MainframeConnection.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Mainframe\MockMainframeConnection.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Security\SensitiveClass.cs" + SubType = "Code" + BuildAction = "Compile" + /> + <File + RelPath = "Security\SensitiveClassTests.cs" SubType = "Code" BuildAction = "Compile" |
From: <gc...@us...> - 2003-03-11 20:31:19
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock In directory sc8-pr-cvs1:/tmp/cvs-serv20785/DotNetMock Modified Files: DotNetMock.csproj Log Message: Index: DotNetMock.csproj =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/DotNetMock.csproj,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** DotNetMock.csproj 7 Oct 2002 00:06:14 -0000 1.8 --- DotNetMock.csproj 11 Mar 2003 20:30:45 -0000 1.9 *************** *** 98,137 **** /> <File ! RelPath = "Expectation.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "ExpectationArrayList.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "ExpectationBool.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "ExpectationCollection.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "ExpectationCounter.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "ExpectationString.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "ExpectationType.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "ExpectationValue.cs" SubType = "Code" BuildAction = "Compile" --- 98,142 ---- /> <File ! RelPath = "ExpectationArrayList.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "ExpectationBool.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "ExpectationCounter.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "ExpectationString.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "ExpectationType.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "ExpectationValue.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "IExpectation.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "IExpectationCollection.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "IVerifiable.cs" SubType = "Code" BuildAction = "Compile" *************** *** 143,147 **** /> <File ! RelPath = "Null.cs" SubType = "Code" BuildAction = "Compile" --- 148,152 ---- /> <File ! RelPath = "NullObject.cs" SubType = "Code" BuildAction = "Compile" *************** *** 153,167 **** /> <File ! RelPath = "Verifiable.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "Verifier.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "Data\MockDataParameter.cs" SubType = "Code" BuildAction = "Compile" --- 158,272 ---- /> <File ! RelPath = "Verifier.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "VerifyException.cs" SubType = "Code" BuildAction = "Compile" /> <File ! RelPath = "Dynamic\DynamicMock.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\IMock.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\IPredicate.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Mock.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Generate\ClassGenerator.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\AndPredicate.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\IsAnything.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\IsCloseTo.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\IsEqual.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\IsEqualIgnoreCase.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\IsEqualIgnoreWhiteSpace.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\IsIn.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\IsMatch.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\IsNull.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\IsTypeOf.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\NotEqual.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\NotIn.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\NotNull.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\NotPredicate.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\OrPredicate.cs" ! SubType = "Code" ! BuildAction = "Compile" ! /> ! <File ! RelPath = "Dynamic\Predicates\Predicate.cs" SubType = "Code" BuildAction = "Compile" |
From: <gc...@us...> - 2003-03-11 20:31:19
|
Update of /cvsroot/dotnetmock/dotnetmock In directory sc8-pr-cvs1:/tmp/cvs-serv20785 Modified Files: DotNetMock.sln Log Message: Index: DotNetMock.sln =================================================================== RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock.sln,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** DotNetMock.sln 30 Oct 2002 04:46:51 -0000 1.4 --- DotNetMock.sln 11 Mar 2003 20:30:43 -0000 1.5 *************** *** 1,9 **** Microsoft Visual Studio Solution File, Format Version 7.00 - Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetMock.Tests", "DotNetMock.Tests\DotNetMock.Tests.csproj", "{0FBE418F-86AF-4E83-B66F-C0177CE582BC}" - EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetMock", "DotNetMock\DotNetMock.csproj", "{1AD0CD00-16FA-4456-B2ED-A47406957228}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetMock.Examples", "DotNetMock.Examples\DotNetMock.Examples.csproj", "{80B98B32-57CB-4989-B506-0F2B0AD94DBA}" EndProject Global GlobalSection(SolutionConfiguration) = preSolution --- 1,13 ---- Microsoft Visual Studio Solution File, Format Version 7.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetMock", "DotNetMock\DotNetMock.csproj", "{1AD0CD00-16FA-4456-B2ED-A47406957228}" EndProject + Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetMock.Tests", "DotNetMock.Tests\DotNetMock.Tests.csproj", "{0FBE418F-86AF-4E83-B66F-C0177CE582BC}" + EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetMock.Examples", "DotNetMock.Examples\DotNetMock.Examples.csproj", "{80B98B32-57CB-4989-B506-0F2B0AD94DBA}" EndProject + Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetMock.Framework", "DotNetMock.Framework\DotNetMock.Framework.csproj", "{514DAB7F-4A05-4343-9BF5-2C3DC60A431D}" + EndProject + Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DotNetMock.Framework.Tests", "DotNetMock.Framework.Tests\DotNetMock.Framework.Tests.csproj", "{32FE638B-E5ED-4886-8F1B-5E35AE6289A5}" + EndProject Global GlobalSection(SolutionConfiguration) = preSolution *************** *** 14,29 **** EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution - {0FBE418F-86AF-4E83-B66F-C0177CE582BC}.Debug.ActiveCfg = Debug|.NET - {0FBE418F-86AF-4E83-B66F-C0177CE582BC}.Debug.Build.0 = Debug|.NET - {0FBE418F-86AF-4E83-B66F-C0177CE582BC}.Release.ActiveCfg = Release|.NET - {0FBE418F-86AF-4E83-B66F-C0177CE582BC}.Release.Build.0 = Release|.NET {1AD0CD00-16FA-4456-B2ED-A47406957228}.Debug.ActiveCfg = Debug|.NET {1AD0CD00-16FA-4456-B2ED-A47406957228}.Debug.Build.0 = Debug|.NET {1AD0CD00-16FA-4456-B2ED-A47406957228}.Release.ActiveCfg = Release|.NET {1AD0CD00-16FA-4456-B2ED-A47406957228}.Release.Build.0 = Release|.NET {80B98B32-57CB-4989-B506-0F2B0AD94DBA}.Debug.ActiveCfg = Debug|.NET {80B98B32-57CB-4989-B506-0F2B0AD94DBA}.Debug.Build.0 = Debug|.NET {80B98B32-57CB-4989-B506-0F2B0AD94DBA}.Release.ActiveCfg = Release|.NET {80B98B32-57CB-4989-B506-0F2B0AD94DBA}.Release.Build.0 = Release|.NET EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution --- 18,41 ---- EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {1AD0CD00-16FA-4456-B2ED-A47406957228}.Debug.ActiveCfg = Debug|.NET {1AD0CD00-16FA-4456-B2ED-A47406957228}.Debug.Build.0 = Debug|.NET {1AD0CD00-16FA-4456-B2ED-A47406957228}.Release.ActiveCfg = Release|.NET {1AD0CD00-16FA-4456-B2ED-A47406957228}.Release.Build.0 = Release|.NET + {0FBE418F-86AF-4E83-B66F-C0177CE582BC}.Debug.ActiveCfg = Debug|.NET + {0FBE418F-86AF-4E83-B66F-C0177CE582BC}.Debug.Build.0 = Debug|.NET + {0FBE418F-86AF-4E83-B66F-C0177CE582BC}.Release.ActiveCfg = Release|.NET + {0FBE418F-86AF-4E83-B66F-C0177CE582BC}.Release.Build.0 = Release|.NET {80B98B32-57CB-4989-B506-0F2B0AD94DBA}.Debug.ActiveCfg = Debug|.NET {80B98B32-57CB-4989-B506-0F2B0AD94DBA}.Debug.Build.0 = Debug|.NET {80B98B32-57CB-4989-B506-0F2B0AD94DBA}.Release.ActiveCfg = Release|.NET {80B98B32-57CB-4989-B506-0F2B0AD94DBA}.Release.Build.0 = Release|.NET + {514DAB7F-4A05-4343-9BF5-2C3DC60A431D}.Debug.ActiveCfg = Debug|.NET + {514DAB7F-4A05-4343-9BF5-2C3DC60A431D}.Debug.Build.0 = Debug|.NET + {514DAB7F-4A05-4343-9BF5-2C3DC60A431D}.Release.ActiveCfg = Release|.NET + {514DAB7F-4A05-4343-9BF5-2C3DC60A431D}.Release.Build.0 = Release|.NET + {32FE638B-E5ED-4886-8F1B-5E35AE6289A5}.Debug.ActiveCfg = Debug|.NET + {32FE638B-E5ED-4886-8F1B-5E35AE6289A5}.Debug.Build.0 = Debug|.NET + {32FE638B-E5ED-4886-8F1B-5E35AE6289A5}.Release.ActiveCfg = Release|.NET + {32FE638B-E5ED-4886-8F1B-5E35AE6289A5}.Release.Build.0 = Release|.NET EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution |
From: <gc...@us...> - 2003-03-11 20:30:58
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework/Xml/XPath In directory sc8-pr-cvs1:/tmp/cvs-serv20785/DotNetMock.Framework/Xml/XPath Added Files: MockXPathNavigable.cs Log Message: --- NEW FILE: MockXPathNavigable.cs --- using System; using System.Xml; using System.Xml.XPath; using DotNetMock; namespace DotNetMock.Xml.XPath { /// <summary> /// Mock Object implementing IXPathNavigable interface /// </summary> public class MockXPathNavigable : MockObject, IXPathNavigable { /// <summary> /// Number of CreateNavigator() calls to expect /// </summary> private ExpectationCounter _createNavigatorCalls = new ExpectationCounter("MockXPathNavigable.CreateNavigatorCount"); /// <summary> /// Exception to throw on CreateNavigator() call /// </summary> private Exception _expectedException = null; /// <summary> /// XPathNavigator to be returned by a CreateNavigator() call /// </summary> private XPathNavigator _expectedNavigator = null; /// <summary> /// Private, internal class that provides empty implementation of the XPathNavigator abstract /// class. If no XPathNavigator is supplied to be returned, then a empty instance of /// DummyXPathNavigator will be returned /// </summary> private class DummyXPathNavigator : XPathNavigator { public override string BaseURI { get { return null; } } public override System.Xml.XPath.XPathNavigator Clone() { return null; } public override string GetAttribute(string localName, string namespaceURI) { return null; } public override string GetNamespace(string name) { return null; } public override bool HasAttributes { get { return true; } } public override bool HasChildren { get { return true; } } public override bool IsEmptyElement { get { return true; } } public override bool IsSamePosition(System.Xml.XPath.XPathNavigator other) { return true; } public override string LocalName { get { return null; } } public override bool MoveTo(System.Xml.XPath.XPathNavigator other) { return true; } public override bool MoveToAttribute(string localName, string namespaceURI) { return true; } public override bool MoveToFirst() { return true; } public override bool MoveToFirstAttribute() { return true; } public override bool MoveToFirstChild() { return true; } public override bool MoveToFirstNamespace(System.Xml.XPath.XPathNamespaceScope namespaceScope) { return true; } public override bool MoveToId(string id) { return true; } public override bool MoveToNamespace(string name) { return true; } public override bool MoveToNext() { return true; } public override bool MoveToNextAttribute() { return true; } public override bool MoveToNextNamespace(System.Xml.XPath.XPathNamespaceScope namespaceScope) { return true; } public override bool MoveToParent() { return true; } public override void MoveToRoot() { } public override string Name { get { return null; } } public override string NamespaceURI { get { return null; } } public override System.Xml.XmlNameTable NameTable { get { return null; } } public override System.Xml.XPath.XPathNodeType NodeType { get { return new System.Xml.XPath.XPathNodeType(); } } public override string Prefix { get { return null; } } public override string Value { get { return null; } } public override string XmlLang { get { return null; } } public override bool MoveToPrevious() { return true; } } /// <summary> /// Default Constructor. /// </summary> public MockXPathNavigable() { this.name = "MockXPathNavigable"; } #region Mock Methods /// <summary> /// Sets exception to throw on CreateNavigator() calls /// </summary> /// <param name="expected">Excepiton to throw</param> public void SetCreateException( Exception expected ) { _expectedException = expected; } /// <summary> /// Sets number of CreateNavigator() calls to expect /// </summary> /// <param name="count">Calls to expect</param> public void SetExpectedCreateCount( int count ) { _createNavigatorCalls.Expected = count; } /// <summary> /// Sets instance of an XPathNavigator subclass to return on CreateNavigator() calls /// </summary> /// <param name="navigator">XPathNavigator subclass to return</param> public void SetExpectedNavigator( XPathNavigator navigator ) { _expectedNavigator = navigator; } #endregion #region Implementation of IXPathNavigable /// <summary> /// 1) Increments the number of CreateNavigator() calls /// 2) If there is an exception to throw, it is thrown /// 3) If there is an expected XPathNavigator to return, it is returned /// 4) Otherwise, a default empty <seealso cref="DummyXPathNavigator">DummyXPathNavigator</seealso> is returned /// </summary> /// <returns></returns> public System.Xml.XPath.XPathNavigator CreateNavigator() { _createNavigatorCalls.Inc(); if ( _expectedException != null ) { throw _expectedException; } if ( _expectedNavigator != null ) { return _expectedNavigator; } else { return (XPathNavigator) new DummyXPathNavigator(); } } #endregion } } |
From: <gc...@us...> - 2003-03-11 20:30:57
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework/Security/Principal In directory sc8-pr-cvs1:/tmp/cvs-serv20785/DotNetMock.Framework/Security/Principal Added Files: MockIIdentity.cs MockIPrincipal.cs Log Message: --- NEW FILE: MockIIdentity.cs --- using System; using DotNetMock; using System.Security.Principal; 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 { get { return _expectedIsAuth; } } /// <summary> /// Returns the name of the current Identity /// </summary> public string Name { get { return _expectedName; } } /// <summary> /// Returns the current Authentication Type /// </summary> public string AuthenticationType { get { return _expectedAuthType; } } #endregion } } --- NEW FILE: MockIPrincipal.cs --- using System; using System.Collections; using System.Security.Principal; using DotNetMock; 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() { this.name = "MockIPrincipal"; _roles = new ArrayList(); } #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 ) { for (int i = 0; i < roles.Length; i++) { AddExpectedRole( roles[i] ); } } #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) { _isInRoleCalls.Inc(); bool found = false; foreach (string role in _roles) { if (role.Equals(roleToSearch)) { found = true; } } return found; } /// <summary> /// Returns the current Identity associated with this Principal /// </summary> public System.Security.Principal.IIdentity Identity { get { return _expectedIdentity; } } #endregion } } |
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework/Data In directory sc8-pr-cvs1:/tmp/cvs-serv20785/DotNetMock.Framework/Data Added Files: MockCommand.cs MockDataParameter.cs MockDataParameterCollection.cs MockDataReader.cs MockDbConnection.cs MockTransaction.cs Log Message: --- NEW FILE: MockCommand.cs --- using System; using System.Data; namespace DotNetMock.Data { /// <summary> /// This Mock Object implements the IDbCommand interface /// </summary> public class MockCommand : MockObject, IDbCommand { private ExpectationString _commandText = new ExpectationString("MockCommand.CommandText"); private ExpectationValue _commandTimeout = new ExpectationValue("MockCommand.CommandTimeout"); private ExpectationValue _commandType = new ExpectationValue("MockCommand.CommandType"); private ExpectationCounter _executeCalls = new ExpectationCounter("MockCommand.ExecuteCalls"); private Exception _executeException = null; private int _updateCount = 0; private MockDbConnection _connection = null; private MockTransaction _transaction = null; private MockDataParameterCollection _parameters = null; private MockDataReader _reader = null; private UpdateRowSource _updateRowSource = UpdateRowSource.None; /// <summary> /// Default constructor /// </summary> public MockCommand() { _parameters = new MockDataParameterCollection(); } #region Mock Methods /// <summary> /// Set update count to be returned from ExecuteNonQuery() /// </summary> /// <param name="count">Count to return</param> public void SetUpdateCount(int count) { _updateCount = count; } /// <summary> /// Set number of Execute calls to be expected /// </summary> /// <param name="calls">Calls to expect</param> public void SetExpectedExecuteCalls(int calls) { _executeCalls.Expected = calls; } /// <summary> /// Set Command Text to be expected /// </summary> /// <param name="commandText">Command Text to be expected</param> public void SetExpectedCommandText(string commandText) { _commandText.Expected = commandText; } /// <summary> /// Set Command Timeout to be expected /// </summary> /// <param name="commandTimeout">Timeout to expect</param> public void SetExpectedCommandTimeout(int commandTimeout) { _commandTimeout.Expected = commandTimeout; } /// <summary> /// Set Command Type to expected. <see cref="System.Data.CommandType"/> /// </summary> /// <param name="commandType">Command Type to expect</param> public void SetExpectedCommandType(System.Data.CommandType commandType) { _commandType.Expected = commandType; } /// <summary> /// Add parameter to expected parameters /// </summary> /// <param name="parameter">Parameter to add</param> public void SetExpectedParameter(IDataParameter parameter) { _parameters.AddExpected(parameter); } /// <summary> /// Set expected Data Reader to return from ExecuteReader() /// </summary> /// <param name="reader">Mock Data Reader to use</param> public void SetExpectedReader(IDataReader reader) { _reader = (MockDataReader)reader; } /// <summary> /// Set exception to throw on execute calls /// </summary> /// <param name="exception">Exception to call</param> public void SetExecuteException(System.Exception exception) { _executeException = exception; } /// <summary> /// Private function called by all execute methods. Serves two functions: /// Increments the ExecuteCalls counter and throws an exception if one is set /// </summary> private void innerExecute() { _executeCalls.Inc(); if (_executeException != null) { throw _executeException; } } #endregion #region Implementation of IDbCommand #region IDbCommand Methods /// <summary> /// Cancel the execution of the command. Currently Not Implemented /// </summary> public void Cancel() { throw new NotImplementedException("Canceling a command is currently not implemented."); } /// <summary> /// Creates a compiled version of the command. Currently Not Implemented /// </summary> public void Prepare() { throw new NotImplementedException("Canceling a command is currently not implemented."); } /// <summary> /// Executes the command, with the given behavior, then returns a Data Reader of results. /// Currently Not Implemented /// </summary> /// <param name="behavior">Command Behavior to use. <see cref="System.Data.CommandBehavior"/></param> /// <returns></returns> public System.Data.IDataReader ExecuteReader(System.Data.CommandBehavior behavior) { throw new NotImplementedException("ExecuteReader with a CommandBehavior parameter currently not implemented."); } /// <summary> /// Increments the number of execute calls and returns the MockDataReader previously setup. /// <see cref="SetExpectedReader()"/> /// </summary> /// <returns>MockDataReader</returns> public System.Data.IDataReader ExecuteReader() { innerExecute(); return _reader; } /// <summary> /// Increments the number of execute calls and returns a null object /// </summary> /// <returns>Null</returns> public object ExecuteScalar() { innerExecute(); return null; } /// <summary> /// Increments the number of execute calls and returns update count. /// <see cref="SetUpdateCount()"/> /// </summary> /// <returns>Update Count</returns> public int ExecuteNonQuery() { innerExecute(); return _updateCount; } /// <summary> /// Creates a new MockDataParameter /// </summary> /// <returns>MockDataParameter</returns> public System.Data.IDbDataParameter CreateParameter() { return (IDbDataParameter) new MockDataParameter(); } #endregion #region IDbCommand Properties // TODO: Implement other CommandTypes: StoredProcedure & TableDirect /// <summary> /// Gets/Sets the actual command type to use. Note: Only CommandType.Text is supported /// <see cref="System.Data.CommandType"/> /// </summary> public System.Data.CommandType CommandType { get { return (CommandType)_commandType.Actual; } set { if (!value.Equals(CommandType.Text)) { throw new NotImplementedException("Only CommandType.Text is currently supported."); } _commandType.Actual = value; } } // TODO: Implement actual CommandTimeout usage /// <summary> /// Gets/Sets actual command timeout to use. Note: Currently, only values of 0 are supported /// </summary> public int CommandTimeout { get { return (int)_commandTimeout.Actual; } set { if (value != 0) { throw new NotImplementedException("Custom CommandTimeout is not currently supported."); } _commandTimeout.Actual = value; } } /// <summary> /// Gets/Sets connection to associate with this command /// </summary> public System.Data.IDbConnection Connection { get { return _connection; } set { if (_connection != value) { this.Transaction = null; } _connection = (MockDbConnection)value; } } /// <summary> /// Gets/Sets how command results are applied to the <see cref="System.Data.DataRow">DataRow</see> /// when used by the <see cref="System.Data.Common.DbDataAdapter.Update">Update</see> method /// of a <see cref="System.Data.Common.DbDataAdapter">DbDataAdapter</see> /// </summary> public System.Data.UpdateRowSource UpdatedRowSource { get { return _updateRowSource; } set { _updateRowSource = value; } } /// <summary> /// Gets/Sets actual command text for this command /// </summary> public string CommandText { get { return _commandText.Actual; } set { _commandText.Actual = value; } } /// <summary> /// Gets the <see cref="DotNetMock.Data.MockDataParameterCollection">MockDataParameterCollection</see> /// </summary> public MockDataParameterCollection Parameters { get { return _parameters; } } /// <summary> /// Gets the <see cref="System.Data.IDataParameterCollection">IDataParameterCollection</see> /// </summary> System.Data.IDataParameterCollection IDbCommand.Parameters { get { return _parameters; } } // TODO: Takes steps to ensure that transaction is compatible with the current connection /// <summary> /// Gets/Sets current transaction associated with this command /// </summary> public System.Data.IDbTransaction Transaction { get { return _transaction; } set { _transaction = (MockTransaction)value; } } #endregion #endregion #region Implementation of IDisposable public void Dispose() { Dispose(true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (disposing) { if (_connection != null) _connection.Dispose(); } } ~MockCommand() { Dispose (false); } #endregion } } --- NEW FILE: MockDataParameter.cs --- using System; using System.Data; namespace DotNetMock.Data { /// <summary> /// This is a Mock object that implements the IDataParameter interface. /// </summary> public class MockDataParameter : MockObject, IDataParameter { private ExpectationBool _nullable = new ExpectationBool("MockDataParameter.IsNullable"); private ExpectationString _parameterName = new ExpectationString("MockDataParameter.Name"); private ExpectationValue _parameterValue = new ExpectationValue("MockDataParameter.Value"); private ExpectationString _parameterSourceColumn = new ExpectationString("MockDataParameter.SourceColumn"); private ExpectationValue _parameterType = new ExpectationValue("MockDataParameter.Type"); /// <summary> /// Default, Empty Constructor /// </summary> public MockDataParameter() {} /// <summary> /// Initializes a new MockDataParameter with the supplied name and of the supplied type /// </summary> /// <param name="name">Name for new parameter</param> /// <param name="newType">Type for new parameter</param> public MockDataParameter(string name, DbType newType) { _parameterName.Actual = name; _parameterType.Actual = newType; } /// <summary> /// Initializes a new MockDataParameter with the supplied name and value /// </summary> /// <param name="name">Name for the new parameter</param> /// <param name="value">Value for the new parameter</param> public MockDataParameter(string name, string value) { _parameterName.Actual = name; _parameterValue.Actual = value; } /// <summary> /// Initializes a new MockDataParameter with supplied name, and of the supplied type, corresponding to the /// supplied column /// </summary> /// <param name="name">Name for the new parameter</param> /// <param name="newType">Type for new parameter</param> /// <param name="sourceColumn">Corresponding column for the parameter</param> public MockDataParameter(string name, DbType newType, string sourceColumn) { _parameterName.Actual = name; _parameterType.Actual = newType; _parameterSourceColumn.Actual = sourceColumn; } /// <summary> /// Sets expected parameter name /// </summary> /// <param name="name">Parameter name to expect</param> public void SetExpectedName(string name) { _parameterName.Expected = name; } /// <summary> /// Sets expected parameter value /// </summary> /// <param name="value">Value to expect</param> public void SetExpectedValue(string value) { _parameterValue.Expected = value; } /// <summary> /// Sets IsNullable or not /// </summary> /// <param name="nullable">True/False</param> public void SetExpectedNullable(bool nullable) { _nullable.Expected = nullable; } /// <summary> /// Sets expected parameter type /// </summary> /// <param name="expectedType">Type to expect</param> public void SetExpectedType(DbType expectedType) { _parameterType.Expected = expectedType; } /// <summary> /// Sets expected source column /// </summary> /// <param name="column">Expected source column</param> public void SetExpectedSourceColumn(string column) { _parameterSourceColumn.Expected = column; } #region Implementation of IDataParameter // TODO: Implement complete directions: Input, Output, InputOutput, and ReturnValue /// <summary> /// Parameter Direction /// </summary> public System.Data.ParameterDirection Direction { get { return new System.Data.ParameterDirection(); } set { } } /// <summary> /// Paramter Type /// </summary> public System.Data.DbType DbType { get { return (DbType)_parameterType.Actual; } set { } } /// <summary> /// Parameter Value /// </summary> public object Value { get { return _parameterValue.Actual; } set { _parameterValue.Actual = value; _parameterType.Actual = inferType(value); } } /// <summary> /// Is Nullable /// </summary> public bool IsNullable { set { _nullable.Actual = value; } get { return _nullable.Actual; } } // TODO: Implement different DataRowVersion information: Current, Proposed, Default, and Original /// <summary> /// Parameter Source Version to use /// </summary> public System.Data.DataRowVersion SourceVersion { get { return DataRowVersion.Current; } set { } } /// <summary> /// Paramter Name /// </summary> public string ParameterName { get { return _parameterName.Actual; } set { } } /// <summary> /// Source Column for the parameter /// </summary> public string SourceColumn { get { return _parameterSourceColumn.Actual; } set { } } #endregion /// <summary> /// Infers corresponding DbType from the given value /// </summary> /// <param name="value">Value to use</param> /// <returns>Inferred DbType from given value</returns> private DbType inferType(Object value) { switch (Type.GetTypeCode(value.GetType())) { case TypeCode.Object: return DbType.Object; case TypeCode.Empty: case TypeCode.DBNull: case TypeCode.Char: case TypeCode.SByte: case TypeCode.UInt16: case TypeCode.UInt32: case TypeCode.UInt64: throw new ApplicationException("Unsupported data type"); case TypeCode.Boolean: return DbType.Boolean; case TypeCode.Byte: return DbType.Byte; case TypeCode.Int16: return DbType.Int16; case TypeCode.Int32: return DbType.Int32; case TypeCode.Int64: return DbType.Int64; case TypeCode.Single: return DbType.Single; case TypeCode.Double: return DbType.Double; case TypeCode.Decimal: return DbType.Decimal; case TypeCode.DateTime: return DbType.DateTime; case TypeCode.String: return DbType.String; default: throw new ApplicationException("Value is of unknown data type"); } } } } --- 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 } } --- NEW FILE: MockDataReader.cs --- using System; using System.Data; using DotNetMock; namespace DotNetMock.Data { /// <summary> /// This Mock Object implements the IDataReader interface. /// </summary> public class MockDataReader : MockObject, IDataReader { private int _recordsAffectedCount = -1; private bool _isClosed = false; private ExpectationCounter _closeCalls = new ExpectationCounter("MockDataReader.CloseCalls"); private ExpectationCounter _readCalls = new ExpectationCounter("MockDataReader.ReadCalls"); private DataTable _schemaTable = null; private object[,] _rows = new object[0,0]; private int _currentRow = -1; private Exception _getException = null; public MockDataReader() {} #region Mock Methods /// <summary> /// Set records affected count to return from RecordsAffected property /// </summary> /// <param name="count">Count to expect</param> public void SetRecordsAffectedCount(int count) { _recordsAffectedCount = count; } /// <summary> /// Set number of Close() calls to expect /// </summary> /// <param name="calls">Count to expect</param> public void SetExpectedCloseCalls(int calls) { _closeCalls.Expected = calls; } /// <summary> /// Sets Schema Table to used /// </summary> /// <param name="schemaTable">DataTable to describe columns</param> public void SetSchemaTable(DataTable schemaTable) { _schemaTable = schemaTable; } /// <summary> /// Set number of Read() calls to expect /// </summary> /// <param name="readCalls">Count to expect</param> public void SetExpectedReadCalls(int readCalls) { _readCalls.Expected = readCalls; } /// <summary> /// Set value of IsClosed property /// </summary> /// <param name="isClosed">True/False</param> public void SetIsClosedValue(bool isClosed) { _isClosed = isClosed; } /// <summary> /// Set data to use for all get calls /// </summary> /// <param name="rows">Two-Dimensional array to read data from. Format: [Row,Column]</param> public void SetRows(object[,] rows) { _rows = rows; } /// <summary> /// Set exception to throw on any GetXXX() calls /// </summary> /// <param name="exception">Exception to throw</param> public void SetGetException(Exception exception) { _getException = exception; } #endregion #region Implementation of IDataReader public void Close() { _closeCalls.Inc(); _isClosed = true; } /// <summary> /// Gets SchemaTable /// </summary> /// <returns></returns> public System.Data.DataTable GetSchemaTable() { return _schemaTable; } /// <summary> /// Advances the data reader to the next result, when reading the result batch SQL statements /// Currently Not Implemented /// </summary> /// <returns>True</returns> public bool NextResult() { this.NotImplemented("MockDataReader.NextResult"); return true; } public bool Read() { _readCalls.Inc(); if (_currentRow + 1 >= _rows.GetLength(0)) { return false; } _currentRow++; return true; } /// <summary> /// Gets a value indicating the depth of nesting for the current row. /// Currently Not Implemented /// </summary> public int Depth { get { this.NotImplemented("MockDataReader.Depth"); return 0; } } /// <summary> /// Gets a value indicating whether the data reader is closed /// </summary> public bool IsClosed { get { return _isClosed; } } /// <summary> /// Gets the number of rows changed, inserted, or deleted by executing the SQL statement /// Returns the value set by SetRecordsAffectedCount() /// </summary> public int RecordsAffected { get { return _recordsAffectedCount; } } #region Implementation of IDisposable public void Dispose() { } #endregion #region Implementation of IDataRecord /// <summary> /// Gets the 32-bit signed integer value of the specified field /// </summary> /// <param name="i">Index of the field to find</param> /// <returns>The 32-bit signed integer value of the specified field.</returns> public int GetInt32(int i) { return Convert.ToInt32(GetValue(i)); } /// <summary> /// Returns the value of the specified field /// </summary> /// <param name="i">Index of the field to find</param> /// <returns>The Object which will contain the field value upon return.</returns> public object GetValue(int i) { if (_getException != null) { throw _getException; } return _rows[_currentRow, i - 1]; } /// <summary> /// Return whether the specified field is set to null /// </summary> /// <param name="i">Index of the field to find</param> /// <returns>true if the specified field is set to null, otherwise false.</returns> public bool IsDBNull(int i) { bool result = true; if (!GetValue(i).Equals("")) { result = false; } return result; } /// <summary> /// Reads a stream of bytes from the specified column offset into the buffer as an array, starting at the given buffer offset. Currently Not Implemented /// </summary> /// <param name="i">The zero-based column ordinal. </param> /// <param name="fieldOffset">The index within the field from which to begin the read operation. </param> /// <param name="buffer">The buffer into which to read the stream of bytes.</param> /// <param name="bufferoffset">The index for buffer to begin the read operation.</param> /// <param name="length">The number of bytes to read.</param> /// <returns>The actual number of bytes read.</returns> public long GetBytes(int i, long fieldOffset, byte[] buffer, int bufferoffset, int length) { this.NotImplemented("MockDataReader.GetBytes"); return 0; } /// <summary> /// Gets the 8-bit unsigned integer value of the specified column. /// </summary> /// <param name="i">The zero-based column ordinal.</param> /// <returns>The 8-bit unsigned integer value of the specified column.</returns> public byte GetByte(int i) { return Convert.ToByte(GetValue(i)); } /// <summary> /// Gets the Type information corresponding to the type of Object that would be returned from GetValue. Currently Not Implemented /// </summary> /// <param name="i">The index of the field to find. </param> /// <returns>The Type information corresponding to the type of Object that would be returned from GetValue.</returns> public System.Type GetFieldType(int i) { this.NotImplemented("MockDataReader.GetFieldType"); return null; } /// <summary> /// Gets the fixed-position numeric value of the specified field. /// </summary> /// <param name="i">The index of the field to find. </param> /// <returns>The fixed-position numeric value of the specified field.</returns> public decimal GetDecimal(int i) { return Convert.ToDecimal(GetValue(i)); } /// <summary> /// Gets all the attribute fields in the collection for the current record. /// </summary> /// <param name="values">An array of Object to copy the attribute fields into. </param> /// <returns>The number of instances of Object in the array.</returns> public int GetValues(object[] values) { this.NotImplemented("MockDataReader.GetValues"); return 0; } /// <summary> /// Gets the name for the field to find. Currently Not Implemented /// </summary> /// <param name="i">The index of the field to find. </param> /// <returns>The name of the field or the empty string (""), if there is no value to return.</returns> public string GetName(int i) { this.NotImplemented("MockDataReader.GetName"); return null; } /// <summary> /// Gets the 64-bit signed integer value of the specified field. /// </summary> /// <param name="i">The index of the field to find. </param> /// <returns>The 64-bit signed integer value of the specified field.</returns> public long GetInt64(int i) { return Convert.ToInt64(GetValue(i)); } /// <summary> /// Gets the double-precision floating point number of the specified field. /// </summary> /// <param name="i">The index of the field to find. </param> /// <returns>The double-precision floating point number of the specified field.</returns> public double GetDouble(int i) { return Convert.ToDouble(GetValue(i)); } /// <summary> /// Gets the value of the specified column as a Boolean. /// </summary> /// <param name="i">The zero-based column ordinal. </param> /// <returns>The value of the column.</returns> public bool GetBoolean(int i) { return Convert.ToBoolean(GetValue(i)); } /// <summary> /// Returns the guid value of the specified field. Currently Not Implemented /// </summary> /// <param name="i">The index of the field to find. </param> /// <returns>The guid value of the specified field.</returns> public System.Guid GetGuid(int i) { this.NotImplemented("MockDataReader.GetGuid"); return new System.Guid(); } /// <summary> /// Gets the date and time data value of the spcified field. /// </summary> /// <param name="i">The index of the field to find. </param> /// <returns>The date and time data value of the spcified field.</returns> public System.DateTime GetDateTime(int i) { return Convert.ToDateTime(GetValue(i)); } /// <summary> /// Return the index of the named field. Currently Not Implemented /// </summary> /// <param name="name">The name of the field to find. </param> /// <returns>The index of the named field.</returns> public int GetOrdinal(string name) { this.NotImplemented("MockDataReader.GetOrdinal"); return 0; } /// <summary> /// Gets the data type information for the specified field. Currently Not Implemented /// </summary> /// <param name="i">The index of the field to find. </param> /// <returns>The data type information for the specified field.</returns> public string GetDataTypeName(int i) { this.NotImplemented("MockDataReader.GetDataTypeName"); return null; } /// <summary> /// Gets the single-precision floating point number of the specified field. Currently Not Implemented /// </summary> /// <param name="i">The index of the field to find. </param> /// <returns>The single-precision floating point number of the specified field.</returns> public float GetFloat(int i) { this.NotImplemented("MockDataReader.GetFloat"); return 0; } /// <summary> /// Gets an IDataReader to be used when the field points to more remote structured data. Currently Not Implemented /// </summary> /// <param name="i">The index of the field to find. </param> /// <returns>An IDataReader to be used when the field points to more remote structured data.</returns> public System.Data.IDataReader GetData(int i) { this.NotImplemented("MockDataReader.GetData"); return null; } /// <summary> /// Reads a stream of characters from the specified column offset into the buffer as an array, starting at the given buffer offset. /// </summary> /// <param name="i">The zero-based column ordinal. </param> /// <param name="fieldoffset">The index within the row from which to begin the read operation. </param> /// <param name="buffer">The buffer into which to read the stream of bytes. </param> /// <param name="bufferoffset">The index for buffer to begin the read operation. </param> /// <param name="length">The number of bytes to read. </param> /// <returns></returns> public long GetChars(int i, long fieldoffset, char[] buffer, int bufferoffset, int length) { this.NotImplemented("MockDataReader.GetChars"); return 0; } /// <summary> /// Gets the string value of the specified field. /// </summary> /// <param name="i">The index of the field to find. </param> /// <returns>The string value of the specified field.</returns> public string GetString(int i) { return Convert.ToString(GetValue(i)); } /// <summary> /// Gets the character value of the specified column. /// </summary> /// <param name="i">The zero-based column ordinal. </param> /// <returns>The character value of the specified column.</returns> public char GetChar(int i) { return Convert.ToChar(GetValue(i)); } /// <summary> /// Gets the 16-bit signed integer value of the specified field. /// </summary> /// <param name="i">The index of the field to find. </param> /// <returns>The 16-bit signed integer value of the specified field.</returns> public short GetInt16(int i) { return Convert.ToInt16(GetValue(i)); } /// <summary> /// Gets the specified column by name. /// </summary> public object this[string name] { get { return this[findColumnIndexForName(name)]; } } /// <summary> /// Gets the specified column by index /// </summary> public object this[int i] { get { return GetValue(i); } } /// <summary> /// Gets the number of columns in the current row. Currently Not Implemented /// </summary> public int FieldCount { get { this.NotImplemented("MockDataReader.FieldCount"); return 0; } } #endregion #endregion /// <summary> /// Finds the index of the given name /// </summary> /// <param name="name">Name of the column to find</param> /// <returns>Column index of the given name</returns> private int findColumnIndexForName(string name) { if (_schemaTable != null) { for (int i = 0; i < _schemaTable.Columns.Count; ++i) { if (_schemaTable.Columns[i].ColumnName.Equals(name)) { return i + 1; } } } throw new IndexOutOfRangeException("Column name: " + name + " not found"); } } } --- NEW FILE: MockDbConnection.cs --- using System; using System.Data; using DotNetMock; namespace DotNetMock.Data { /// <summary> /// This Mock Object implements the IDbConnection interface /// </summary> public class MockDbConnection : MockObject, IDbConnection { private IDbCommand _command; private ExpectationCounter _closeCalls = new ExpectationCounter("MockDbConnection.CloseCalls"); private ExpectationCounter _createCalls = new ExpectationCounter("MockDbConnection.CreateCalls"); private ExpectationString _connectionString = new ExpectationString("MockDbConnection.ConnectionString"); private Exception _createCommandException = null; /// <summary> /// Default Constructor /// </summary> public MockDbConnection() { } #region Mock Methods public void SetExpectedConnectionString(string connectionString) { _connectionString.Expected = connectionString; } /// <summary> /// Set expected command to return on CreateCommand() /// </summary> /// <param name="command">Command to return</param> public void SetupCommand(IDbCommand command) { _command = command; } /// <summary> /// Set expected number of Close() calls to expect /// </summary> /// <param name="calls">Count to expect</param> public void SetExpectedCloseCalls(int calls) { _closeCalls.Expected = calls; } /// <summary> /// Set exception to throw when CreateCommand() is called /// </summary> /// <param name="exception">Exception to throw</param> public void SetCreateCommandException(Exception exception) { _createCommandException = exception; } /// <summary> /// Set expected number of CreateCommand() calls /// </summary> /// <param name="calls">Count to expect</param> public void SetExpectedCreateCalls(int calls) { _createCalls.Expected = calls; } #endregion #region Implementation of IDbConnection /// <summary> /// Changes the current database for an open connection object. Current Not Implemented /// </summary> /// <param name="databaseName">Database to change to</param> public void ChangeDatabase(string databaseName) { this.NotImplemented("MockDbConnection.ChangeDatabase"); } /// <summary> /// Begins a database transaction. Currently Not Implemented /// </summary> /// <param name="il">One of the IsolationLevel values. </param> /// <returns>An object representing the new transaction.</returns> public System.Data.IDbTransaction BeginTransaction(System.Data.IsolationLevel il) { this.NotImplemented("MockDbConnection.BeginTransaction"); return null; } /// <summary> /// Begins a database transaction. /// </summary> /// <returns>An object representing the new transaction.</returns> public System.Data.IDbTransaction BeginTransaction() { return null; } /// <summary> /// Increments Create calls counter then returns the command object designated by the /// SetupCommand method or throws exception /// </summary> /// <returns>Command Object</returns> public System.Data.IDbCommand CreateCommand() { _createCalls.Inc(); if (_createCommandException == null) { return _command; } else { throw _createCommandException; } } /// <summary> /// Opens a database connection with the settings specified by the ConnectionString property of the provider-specific Connection object. /// </summary> public void Open() { this.NotImplemented("MockDbConnection.Open"); } /// <summary> /// Increments CloseCalls counter /// </summary> public void Close() { _closeCalls.Inc(); } /// <summary> /// Gets the current state of the Connection /// </summary> public System.Data.ConnectionState State { get { return new System.Data.ConnectionState(); } } /// <summary> /// Gets/Sets the string used to open a database /// </summary> public string ConnectionString { get { return _connectionString.Actual; } set { _connectionString.Actual = value; } } /// <summary> /// Gets the name of the current database or the database to be used once a connection is open /// </summary> public string Database { get { return null; } } /// <summary> /// Gets the time to wait while trying to establish a connection before terminating the attempt and generating an error /// </summary> public int ConnectionTimeout { get { return 0; } } #endregion #region Implementation of IDisposable /// <summary> /// Releases resources used by MockDbConnection /// </summary> public void Dispose() { } #endregion } } --- NEW FILE: MockTransaction.cs --- using System; using System.Data; namespace DotNetMock.Data { /// <summary> /// This Mock Object implements the IDbTransaction interface /// </summary> public class MockTransaction : MockObject, IDbTransaction { /// <summary> /// Default Constructor /// </summary> public MockTransaction() { } #region Implementation of IDbTransaction /// <summary> /// Rolls back a transaction from a pending state. Currently Not Implemented /// </summary> public void Rollback() { this.NotImplemented("MockTransaction.Rollback"); } /// <summary> /// Commits the database transaction /// </summary> public void Commit() { this.NotImplemented("MockTransaction.Commit"); } /// <summary> /// Gets the Connection object associated with the transaction. Currently Not Implemented /// </summary> public System.Data.IDbConnection Connection { get { this.NotImplemented("MockTransaction.Connection"); return null; } } /// <summary> /// Gets the IsolationLevel for this transaction. Currently Not Implemented /// </summary> public System.Data.IsolationLevel IsolationLevel { get { this.NotImplemented("MockTransaction.IsolationLevel"); return System.Data.IsolationLevel.Unspecified; } } #endregion #region Implementation of IDisposable /// <summary> /// Releases the resources used by MockTransaciton /// </summary> public void Dispose() { } #endregion } } |
From: <gc...@us...> - 2003-03-11 20:05:29
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Xml/XPath In directory sc8-pr-cvs1:/tmp/cvs-serv9039/Xml/XPath Added Files: MockXPathNavigableTests.cs Log Message: --- NEW FILE: MockXPathNavigableTests.cs --- using System; using System.Xml; using System.Xml.XPath; using NUnit.Framework; using DotNetMock.Xml.XPath; namespace DotNetMock.Tests.Xml.XPath { [TestFixture] public class MockXPathNavigableTests { private class TestXPathNavigator : XPathNavigator { public override string BaseURI { get { return null; } } public override System.Xml.XPath.XPathNavigator Clone() { return null; } public override string GetAttribute(string localName, string namespaceURI) { return null; } public override string GetNamespace(string name) { return null; } public override bool HasAttributes { get { return true; } } public override bool HasChildren { get { return true; } } public override bool IsEmptyElement { get { return true; } } public override bool IsSamePosition(System.Xml.XPath.XPathNavigator other) { return true; } public override string LocalName { get { return null; } } public override bool MoveTo(System.Xml.XPath.XPathNavigator other) { return true; } public override bool MoveToAttribute(string localName, string namespaceURI) { return true; } public override bool MoveToFirst() { return true; } public override bool MoveToFirstAttribute() { return true; } public override bool MoveToFirstChild() { return true; } public override bool MoveToFirstNamespace(System.Xml.XPath.XPathNamespaceScope namespaceScope) { return true; } public override bool MoveToId(string id) { return true; } public override bool MoveToNamespace(string name) { return true; } public override bool MoveToNext() { return true; } public override bool MoveToNextAttribute() { return true; } public override bool MoveToNextNamespace(System.Xml.XPath.XPathNamespaceScope namespaceScope) { return true; } public override bool MoveToParent() { return true; } public override void MoveToRoot() { } public override string Name { get { return null; } } public override string NamespaceURI { get { return null; } } public override System.Xml.XmlNameTable NameTable { get { return null; } } public override System.Xml.XPath.XPathNodeType NodeType { get { return new System.Xml.XPath.XPathNodeType(); } } public override string Prefix { get { return null; } } public override string Value { get { return null; } } public override string XmlLang { get { return null; } } public override bool MoveToPrevious() { return true; } } private MockXPathNavigable mockNav = null; [SetUp] public void init() { mockNav = new MockXPathNavigable(); } [TearDown] public void Destroy() { mockNav = null; } [Test] public void CreateNavigatorExpectedCount() { mockNav.SetExpectedCreateCount(2); mockNav.CreateNavigator(); mockNav.CreateNavigator(); mockNav.Verify(); } [Test] [ExpectedException(typeof(AssertionException))] public void CreateNavigatorExpectedCountFails() { mockNav.SetExpectedCreateCount(2); mockNav.CreateNavigator(); mockNav.Verify(); } [Test] [ExpectedException(typeof(XmlException))] public void ExceptionCreateNavigator() { mockNav.SetCreateException(new XmlException("", null)); mockNav.CreateNavigator(); } [Test] public void ExpectedNavigator() { XPathNavigator expectedNav = new TestXPathNavigator(); mockNav.SetExpectedNavigator( expectedNav ); Assertion.AssertEquals("Navigators not equal.", expectedNav, mockNav.CreateNavigator()); } [Test] public void DummyNavigator() { XPathNavigator navigator = null; navigator = mockNav.CreateNavigator(); Assertion.AssertNotNull( "Navigator should never be null.", navigator ); Assertion.AssertEquals( "Navigators should equal.", typeof(XPathNavigator), navigator.GetType().BaseType ); } } } |
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(); } } } |
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Data In directory sc8-pr-cvs1:/tmp/cvs-serv9039/Data Added Files: MockCommandTests.cs MockDataParameterCollectionTests.cs MockDataParameterTests.cs MockDataReaderTests.cs MockDbConnectionTests.cs Log Message: --- NEW FILE: MockCommandTests.cs --- using System; using System.Data; using NUnit.Framework; using DotNetMock.Data; namespace DotNetMock.Tests.Data { /// <summary> /// Summary description for MockCommandTests. /// </summary> [TestFixture] public class MockCommandTests { private MockCommand _mockCmd = null; [TearDown] public void Destroy() { _mockCmd = null; } [Test] public void CommandTextProperty() { _mockCmd = new MockCommand(); _mockCmd.SetExpectedCommandText(@"user id=sa;password=password;Connect Timeout=30"); _mockCmd.CommandText = @"user id=sa;password=password;Connect Timeout=30"; _mockCmd.Verify(); } [Test] [ExpectedException(typeof(AssertionException))] public void InValidCommandTextProperty() { _mockCmd = new MockCommand(); _mockCmd.SetExpectedCommandText(@"user id=sa;password=password;Connect Timeout=30"); _mockCmd.Verify(); } [Test] public void CommandTimeoutProperty() { _mockCmd = new MockCommand(); _mockCmd.SetExpectedCommandTimeout(0); _mockCmd.CommandTimeout = 0; _mockCmd.Verify(); } [Test] [ExpectedException(typeof(NotImplementedException))] public void InValidCommandTimeoutProperty() { _mockCmd = new MockCommand(); _mockCmd.SetExpectedCommandTimeout(30); _mockCmd.CommandTimeout = 30; _mockCmd.Verify(); } [Test] public void CommandTypeProperty() { _mockCmd = new MockCommand(); _mockCmd.SetExpectedCommandType(System.Data.CommandType.Text); _mockCmd.CommandType = System.Data.CommandType.Text; _mockCmd.Verify(); } [Test] [ExpectedException(typeof(NotImplementedException))] public void InValidCommandTypeProperty() { _mockCmd = new MockCommand(); _mockCmd.SetExpectedCommandType(System.Data.CommandType.StoredProcedure); _mockCmd.CommandType = System.Data.CommandType.StoredProcedure; _mockCmd.Verify(); } [Test] public void ConnectionProperty() { _mockCmd = new MockCommand(); MockDbConnection mockConnection = new MockDbConnection(); MockTransaction mockTransaction = new MockTransaction(); _mockCmd.Transaction = mockTransaction; NUnit.Framework.Assertion.AssertNotNull(_mockCmd.Transaction); _mockCmd.Connection = mockConnection; NUnit.Framework.Assertion.AssertNotNull(_mockCmd.Connection); NUnit.Framework.Assertion.AssertEquals(typeof(MockDbConnection), _mockCmd.Connection.GetType()); _mockCmd.Dispose(); } [Test] public void ParametersProperty() { _mockCmd = new MockCommand(); MockDataParameter mockParameter = new MockDataParameter("@inpID", "123456"); _mockCmd.SetExpectedParameter(mockParameter); _mockCmd.Parameters.Add(mockParameter); _mockCmd.Verify(); NUnit.Framework.Assertion.AssertEquals(typeof(MockDataParameterCollection), _mockCmd.Parameters.GetType()); } [Test] [ExpectedException(typeof(AssertionException))] public void InValidParametersProperty() { _mockCmd = new MockCommand(); _mockCmd.SetExpectedParameter(new MockDataParameter("@inpID", "123456")); _mockCmd.Verify(); } [Test] public void ExecuteCalls() { _mockCmd = new MockCommand(); _mockCmd.SetExpectedExecuteCalls(5); _mockCmd.ExecuteNonQuery(); _mockCmd.ExecuteReader(); _mockCmd.ExecuteScalar(); _mockCmd.ExecuteScalar(); _mockCmd.ExecuteNonQuery(); _mockCmd.Verify(); } [Test] [ExpectedException(typeof(AssertionException))] public void InValidExecuteCalls() { _mockCmd = new MockCommand(); _mockCmd.SetExpectedExecuteCalls(2); _mockCmd.ExecuteNonQuery(); _mockCmd.Verify(); } } } --- 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: MockDataParameterTests.cs --- using System; using System.Data; using NUnit.Framework; using DotNetMock.Data; namespace DotNetMock.Tests.Data { /// <summary> /// Summary description for MockDataParameterTests. /// </summary> [TestFixture] public class MockDataParameterTests { private MockDataParameter _mockDataParameter = null; [SetUp] public void Init() { } [TearDown] public void Destroy() { _mockDataParameter = null; } [Test] [ExpectedException(typeof(AssertionException))] public void IsNullable() { _mockDataParameter = new MockDataParameter(); _mockDataParameter.SetExpectedNullable(true); _mockDataParameter.IsNullable = true; _mockDataParameter.Verify(); _mockDataParameter.SetExpectedNullable(false); _mockDataParameter.Verify(); } [Test] [ExpectedException(typeof(AssertionException))] public void ConstructorNameValue() { _mockDataParameter = new MockDataParameter("@inpID", "123456"); _mockDataParameter.SetExpectedName("@inpID"); _mockDataParameter.SetExpectedValue("123456"); _mockDataParameter.Verify(); _mockDataParameter.SetExpectedName("@inpPassword"); _mockDataParameter.SetExpectedValue("654321"); _mockDataParameter.Verify(); } [Test] public void ConstructorNameTypeSourceColumn() { _mockDataParameter = new MockDataParameter("@inpID", DbType.String, "ID"); _mockDataParameter.SetExpectedName("@inpID"); _mockDataParameter.SetExpectedType(DbType.String); _mockDataParameter.SetExpectedSourceColumn("ID"); _mockDataParameter.Verify(); _mockDataParameter.SetExpectedType(DbType.Int32); try { _mockDataParameter.Verify(); NUnit.Framework.Assertion.Fail("Should have thrown an exception."); } catch (NUnit.Framework.AssertionException ex) { } _mockDataParameter.SetExpectedSourceColumn("Fake"); _mockDataParameter.SetExpectedType(DbType.String); try { _mockDataParameter.Verify(); NUnit.Framework.Assertion.Fail("Should have thrown an exception."); } catch (NUnit.Framework.AssertionException ex) { } } [Test] [ExpectedException(typeof(AssertionException))] public void ConstructorNameType() { _mockDataParameter = new MockDataParameter("@inpID", DbType.String); _mockDataParameter.SetExpectedName("@inpID"); _mockDataParameter.SetExpectedType(DbType.String); _mockDataParameter.Verify(); _mockDataParameter.SetExpectedType(DbType.Int32); _mockDataParameter.Verify(); } [Test] [ExpectedException(typeof(AssertionException))] public void SetValue() { _mockDataParameter = new MockDataParameter(); _mockDataParameter.SetExpectedValue("ID"); _mockDataParameter.SetExpectedType(DbType.String); _mockDataParameter.Value = "ID"; _mockDataParameter.Verify(); _mockDataParameter.SetExpectedType(DbType.Int32); _mockDataParameter.Verify(); } } } --- NEW FILE: MockDataReaderTests.cs --- using System; using System.Data; using DotNetMock.Data; using NUnit.Framework; namespace DotNetMock.Tests.Data { [TestFixture] public class MockDataReaderTests { private MockDataReader _reader = null; [SetUp] public void Init() { _reader = new MockDataReader(); } [TearDown] public void Destroy() { _reader = null; } [Test] public void RecordsAffectedSuccess() { _reader.SetRecordsAffectedCount(1); Assertion.AssertEquals("Records affected not equal.", 1, _reader.RecordsAffected); } [Test] [ExpectedException(typeof(AssertionException))] public void RecordsAffectedFails() { _reader.SetRecordsAffectedCount(2); Assertion.AssertEquals(3, _reader.RecordsAffected); } [Test] public void CloseCountCallsSuccess() { _reader.SetExpectedCloseCalls(3); _reader.Close(); _reader.Close(); _reader.Close(); _reader.Verify(); } [Test] [ExpectedException(typeof(AssertionException))] public void CloseCountCallsFails() { _reader.SetExpectedCloseCalls(1); _reader.Close(); _reader.Close(); _reader.Verify(); } [Test] public void GetSchemsTableSuccess() { DataTable dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("ID", typeof(int))); dataTable.Columns.Add(new DataColumn("Password", typeof(string))); dataTable.Columns.Add(new DataColumn("Email", typeof(string))); _reader.SetSchemaTable(dataTable); DataTable dataTable2 = new DataTable(); dataTable2.Columns.Add(new DataColumn("ID", typeof(int))); dataTable2.Columns.Add(new DataColumn("Password", typeof(string))); dataTable2.Columns.Add(new DataColumn("Email", typeof(string))); Assertion.Equals(dataTable2, _reader.GetSchemaTable()); } [Test] public void GetSchemaTableFails() { Assertion.AssertNull("Schema Table isn't empty.", _reader.GetSchemaTable()); } [Test] public void IsClosedSuccess() { _reader.SetIsClosedValue(true); Assertion.Assert(_reader.IsClosed); } [Test] public void IsCloseDefaultValue() { Assertion.Assert(!_reader.IsClosed); } [Test] public void ReadCountCallsSuccess() { _reader.SetExpectedReadCalls(3); _reader.Read(); _reader.Read(); _reader.Read(); _reader.Verify(); } [Test] [ExpectedException(typeof(AssertionException))] public void ReadCountCallsFails() { _reader.SetExpectedReadCalls(2); _reader.Read(); _reader.Read(); _reader.Read(); _reader.Verify(); } [Test] public void ReadSuccess() { _reader.SetExpectedReadCalls(3); _reader.SetRows(createObjectValues()); while (_reader.Read()) { } _reader.Verify(); } [Test] [ExpectedException(typeof(AssertionException))] public void ReadFailure() { _reader.SetExpectedReadCalls(2); _reader.SetRows(createObjectValues()); while (_reader.Read()) { } _reader.Verify(); } [Test] public void GetValueSuccess() { _reader.SetExpectedReadCalls(3); _reader.SetRows(createObjectValues()); int rowCount = 0; while (_reader.Read()) { for (int i = 0; i <= 1; i++) { Assertion.AssertEquals("Items not equal.", "Row " + rowCount + ", Column " + i, _reader.GetValue(i + 1)); } rowCount++; } _reader.Verify(); } [Test] public void IndexerIntSuccess() { _reader.SetExpectedReadCalls(3); _reader.SetRows(createObjectValues()); int rowCount = 0; while (_reader.Read()) { for (int i = 0; i <= 1; i++) { Assertion.AssertEquals("Items not equal.", "Row " + rowCount + ", Column " + i, _reader[i + 1]); } rowCount++; } _reader.Verify(); } [Test] [ExpectedException(typeof(IndexOutOfRangeException))] public void IndexerIntFails() { _reader.SetExpectedReadCalls(3); _reader.SetRows(createObjectValues()); int rowCount = 0; while (_reader.Read()) { for (int i = 0; i <= 1; i++) { Assertion.AssertEquals("Items not equal.", "Row " + rowCount + ", Column " + i, _reader[i + 3]); } rowCount++; } _reader.Verify(); } [Test] public void GetIntSuccess() { object[,] values = new object[2,2]; values[0,0] = 0; values[0,1] = 1; values[1,0] = 0; values[1,1] = 1; _reader.SetRows(values); _reader.SetExpectedReadCalls(3); while (_reader.Read()) { Assertion.AssertEquals(0, _reader.GetInt32(1)); Assertion.AssertEquals(1, _reader.GetInt32(2)); } _reader.Verify(); } [Test] [ExpectedException(typeof(IndexOutOfRangeException))] public void GetIntFails() { object[,] values = new object[2,2]; values[0,0] = 0; values[0,1] = 1; values[1,0] = 0; values[1,1] = 1; _reader.SetRows(values); _reader.SetExpectedReadCalls(3); while (_reader.Read()) { Assertion.AssertEquals(0, _reader.GetInt32(0)); Assertion.AssertEquals(1, _reader.GetInt32(1)); } _reader.Verify(); } [Test] public void IndexerStringSuccess() { _reader.SetExpectedReadCalls(2); DataTable dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("ID", typeof(int))); dataTable.Columns.Add(new DataColumn("Password", typeof(string))); _reader.SetSchemaTable(dataTable); object[,] values = new object[1,2]; values[0,0] = 123456; values[0,1] = "password"; _reader.SetRows(values); while (_reader.Read()) { Assertion.AssertEquals(123456, _reader["ID"]); Assertion.AssertEquals("password", _reader["Password"]); } _reader.Verify(); } [Test] [ExpectedException(typeof(IndexOutOfRangeException))] public void IndexerStringFails() { DataTable dataTable = new DataTable(); dataTable.Columns.Add(new DataColumn("ID", typeof(int))); dataTable.Columns.Add(new DataColumn("Password", typeof(string))); _reader.SetSchemaTable(dataTable); object[,] values = new object[2,2]; values[0,0] = 123456; values[0,1] = "password"; _reader.SetRows(values); while (_reader.Read()) { Assertion.AssertEquals(123456, _reader["Fakes"]); } _reader.Verify(); } private object[,] createObjectValues() { object[,] values = new object[2,2]; values[0,0] = "Row 0, Column 0"; values[0,1] = "Row 0, Column 1"; values[1,0] = "Row 1, Column 0"; values[1,1] = "Row 1, Column 1"; return values; } } } --- 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-03-11 20:02:57
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Xml/XPath In directory sc8-pr-cvs1:/tmp/cvs-serv8005/XPath Log Message: Directory /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Xml/XPath added to the repository |
From: <gc...@us...> - 2003-03-11 20:02:41
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Security/Principal In directory sc8-pr-cvs1:/tmp/cvs-serv7954/Principal Log Message: Directory /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Security/Principal added to the repository |
From: <gc...@us...> - 2003-03-11 20:02:37
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Xml In directory sc8-pr-cvs1:/tmp/cvs-serv7853/Xml Log Message: Directory /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Xml added to the repository |
From: <gc...@us...> - 2003-03-11 20:02:37
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Security In directory sc8-pr-cvs1:/tmp/cvs-serv7853/Security Log Message: Directory /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Security added to the repository |
From: <gc...@us...> - 2003-03-11 20:02:36
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Data In directory sc8-pr-cvs1:/tmp/cvs-serv7853/Data Log Message: Directory /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework.Tests/Data added to the repository |
From: <gc...@us...> - 2003-03-11 20:01:58
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework/Xml/XPath In directory sc8-pr-cvs1:/tmp/cvs-serv7596/XPath Log Message: Directory /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework/Xml/XPath added to the repository |
From: <gc...@us...> - 2003-03-11 20:01:46
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework/Security/Principal In directory sc8-pr-cvs1:/tmp/cvs-serv7525/Principal Log Message: Directory /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework/Security/Principal added to the repository |
From: <gc...@us...> - 2003-03-11 20:01:37
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework/Xml In directory sc8-pr-cvs1:/tmp/cvs-serv7431/Xml Log Message: Directory /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework/Xml added to the repository |
From: <gc...@us...> - 2003-03-11 20:01:37
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework/Data In directory sc8-pr-cvs1:/tmp/cvs-serv7431/Data Log Message: Directory /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework/Data added to the repository |
From: <gc...@us...> - 2003-03-11 20:01:37
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework/Security In directory sc8-pr-cvs1:/tmp/cvs-serv7431/Security Log Message: Directory /cvsroot/dotnetmock/dotnetmock/DotNetMock.Framework/Security added to the repository |
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/data In directory sc8-pr-cvs1:/tmp/cvs-serv25065/data Removed Files: MockDataParameterCollectionTests.cs MockDataParameterTests.cs MockDbConnectionTests.cs mockcommandtests.cs mockdatareadertests.cs Log Message: Move files into seperate project --- MockDataParameterCollectionTests.cs DELETED --- --- MockDataParameterTests.cs DELETED --- --- MockDbConnectionTests.cs DELETED --- --- mockcommandtests.cs DELETED --- --- mockdatareadertests.cs DELETED --- |
From: <gc...@us...> - 2003-03-11 19:27:52
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Security/Principal In directory sc8-pr-cvs1:/tmp/cvs-serv25065/Security/Principal Removed Files: MockIIdentityTests.cs MockIPrincipalTests.cs Log Message: Move files into seperate project --- MockIIdentityTests.cs DELETED --- --- MockIPrincipalTests.cs DELETED --- |
From: <gc...@us...> - 2003-03-11 19:27:52
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock.Tests/Xml/XPath In directory sc8-pr-cvs1:/tmp/cvs-serv25065/Xml/XPath Removed Files: MockXPathNavigableTests.cs Log Message: Move files into seperate project --- MockXPathNavigableTests.cs DELETED --- |
From: <gc...@us...> - 2003-03-11 19:23:55
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Xml/XPath In directory sc8-pr-cvs1:/tmp/cvs-serv23309/Xml/XPath Removed Files: MockXPathNavigable.cs Log Message: Moved Framework files into seperate projects --- MockXPathNavigable.cs DELETED --- |
From: <gc...@us...> - 2003-03-11 19:23:55
|
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Security/Principal In directory sc8-pr-cvs1:/tmp/cvs-serv23309/Security/Principal Removed Files: MockIIdentity.cs MockIPrincipal.cs Log Message: Moved Framework files into seperate projects --- MockIIdentity.cs DELETED --- --- MockIPrincipal.cs DELETED --- |
Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Data In directory sc8-pr-cvs1:/tmp/cvs-serv23309/Data Removed Files: MockCommand.cs MockDataParameter.cs MockDataParameterCollection.cs MockDataReader.cs MockDbConnection.cs mockTransaction.cs Log Message: Moved Framework files into seperate projects --- MockCommand.cs DELETED --- --- MockDataParameter.cs DELETED --- --- MockDataParameterCollection.cs DELETED --- --- MockDataReader.cs DELETED --- --- MockDbConnection.cs DELETED --- --- mockTransaction.cs DELETED --- |