Update of /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10674/DotNetMock/Dynamic
Modified Files:
DynamicMock.cs DynamicOrderedMock.cs
Log Message:
fixed up nextExpectation so that it can be used by DynamicOrderedMock and got rid of some redundant code.
Index: DynamicOrderedMock.cs
===================================================================
RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/DynamicOrderedMock.cs,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** DynamicOrderedMock.cs 19 Feb 2005 21:47:56 -0000 1.10
--- DynamicOrderedMock.cs 19 Feb 2005 22:14:28 -0000 1.11
***************
*** 44,60 ****
}
/// <summary>
! /// Uses the given method to verify expectations for the method. Also verifies method call order.
/// </summary>
! /// <param name="mi">mathod called</param>
! /// <param name="args">arguments to the method</param>
! /// <returns>Return value, if any, from method call.</returns>
! public override object Call(MethodInfo mi, params object[] args)
{
- MethodCall methodCall = new MethodCall(mi, args);
- string methodName = methodCall.MethodName;
- if (values.Contains(methodName))
- {
- return values[methodName];
- }
if (expectations.Count == 0)
{
--- 44,68 ----
}
/// <summary>
! /// Adds a <see cref="ExpectationMethod"/> to the list of expectations of the mock object.
/// </summary>
! /// <param name="e">Expectation to add</param>
! protected override void addExpectation(ExpectationMethod e)
! {
! expectations.Add(e);
! }
! /// <summary>
! /// Retrieve next expectation and remove from FIFO.
! /// </summary>
! /// <param name="methodCall">
! /// <see cref="MethodCall"/> to get expectation for
! /// </param>
! /// <returns>next <see cref="ExpectationMethod"/></returns>
! /// <remarks>
! /// This is a state mutating method. It removes the expectation from
! /// a list. Not a big deal since we don't ever recover from any
! /// exceptions.
! /// </remarks>
! protected override ExpectationMethod nextExpectation(MethodCall methodCall)
{
if (expectations.Count == 0)
{
***************
*** 66,80 ****
ExpectationMethod e = (ExpectationMethod)expectations[0];
expectations.RemoveAt(0);
! e.ActualMethodCall = methodCall;
! e.Verify();
! return e.ReturnValue;
! }
! /// <summary>
! /// Adds a <see cref="ExpectationMethod"/> to the list of expectations of the mock object.
! /// </summary>
! /// <param name="e">Expectation to add</param>
! protected override void addExpectation(ExpectationMethod e)
! {
! expectations.Add(e);
}
}
--- 74,78 ----
ExpectationMethod e = (ExpectationMethod)expectations[0];
expectations.RemoveAt(0);
! return e;
}
}
Index: DynamicMock.cs
===================================================================
RCS file: /cvsroot/dotnetmock/dotnetmock/DotNetMock/Dynamic/DynamicMock.cs,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** DynamicMock.cs 19 Feb 2005 22:05:56 -0000 1.18
--- DynamicMock.cs 19 Feb 2005 22:14:28 -0000 1.19
***************
*** 190,194 ****
return values[methodName];
}
! ExpectationMethod e = nextExpectation(methodName);
e.ActualMethodCall = methodCall;
e.Verify();
--- 190,194 ----
return values[methodName];
}
! ExpectationMethod e = nextExpectation(methodCall);
e.ActualMethodCall = methodCall;
e.Verify();
***************
*** 212,217 ****
/// Retrieve next expectation and remove from FIFO.
/// </summary>
! /// <param name="methodName">
! /// name of method to get expectation for
/// </param>
/// <returns>next <see cref="ExpectationMethod"/></returns>
--- 212,217 ----
/// Retrieve next expectation and remove from FIFO.
/// </summary>
! /// <param name="methodCall">
! /// <see cref="MethodCall"/> to get expectation for
/// </param>
/// <returns>next <see cref="ExpectationMethod"/></returns>
***************
*** 221,226 ****
/// exceptions.
/// </remarks>
! protected virtual ExpectationMethod nextExpectation(string methodName)
{
IList list = (IList) expectations[methodName];
if (list == null)
--- 221,227 ----
/// exceptions.
/// </remarks>
! protected virtual ExpectationMethod nextExpectation(MethodCall methodCall)
{
+ string methodName = methodCall.MethodName;
IList list = (IList) expectations[methodName];
if (list == null)
|