You can subscribe to this list here.
| 2002 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(31) |
Dec
(26) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2003 |
Jan
(8) |
Feb
(27) |
Mar
(15) |
Apr
|
May
(2) |
Jun
(13) |
Jul
(59) |
Aug
(48) |
Sep
(9) |
Oct
(4) |
Nov
(24) |
Dec
|
| 2004 |
Jan
(24) |
Feb
(2) |
Mar
(12) |
Apr
(9) |
May
(4) |
Jun
(26) |
Jul
(20) |
Aug
(23) |
Sep
(13) |
Oct
(31) |
Nov
(23) |
Dec
(11) |
| 2005 |
Jan
|
Feb
|
Mar
|
Apr
(19) |
May
(64) |
Jun
(7) |
Jul
(20) |
Aug
(1) |
Sep
(6) |
Oct
|
Nov
(3) |
Dec
|
| 2006 |
Jan
|
Feb
(69) |
Mar
(18) |
Apr
(1) |
May
(4) |
Jun
(3) |
Jul
(27) |
Aug
(19) |
Sep
(12) |
Oct
(3) |
Nov
(13) |
Dec
(6) |
| 2007 |
Jan
(20) |
Feb
(17) |
Mar
(1) |
Apr
(3) |
May
(4) |
Jun
(11) |
Jul
(10) |
Aug
(24) |
Sep
(19) |
Oct
(13) |
Nov
(8) |
Dec
(7) |
| 2008 |
Jan
(54) |
Feb
(24) |
Mar
(11) |
Apr
(35) |
May
(13) |
Jun
(10) |
Jul
(30) |
Aug
(18) |
Sep
(21) |
Oct
(18) |
Nov
(40) |
Dec
(76) |
| 2009 |
Jan
(64) |
Feb
(23) |
Mar
(15) |
Apr
(23) |
May
(46) |
Jun
(25) |
Jul
(31) |
Aug
(7) |
Sep
(7) |
Oct
(6) |
Nov
(15) |
Dec
(19) |
| 2010 |
Jan
(13) |
Feb
(8) |
Mar
(6) |
Apr
(4) |
May
(8) |
Jun
(7) |
Jul
(3) |
Aug
(9) |
Sep
(6) |
Oct
(15) |
Nov
(3) |
Dec
(5) |
| 2011 |
Jan
(1) |
Feb
|
Mar
(4) |
Apr
(5) |
May
(2) |
Jun
|
Jul
(2) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(2) |
Dec
(3) |
| 2012 |
Jan
(6) |
Feb
(2) |
Mar
(3) |
Apr
(3) |
May
(3) |
Jun
(1) |
Jul
|
Aug
|
Sep
(2) |
Oct
(2) |
Nov
|
Dec
(1) |
| 2013 |
Jan
(3) |
Feb
(1) |
Mar
|
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
(5) |
Sep
|
Oct
(1) |
Nov
(2) |
Dec
|
| 2014 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
(1) |
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
(1) |
| 2015 |
Jan
|
Feb
(19) |
Mar
(115) |
Apr
(23) |
May
(41) |
Jun
(48) |
Jul
(59) |
Aug
(29) |
Sep
(40) |
Oct
(78) |
Nov
(58) |
Dec
(47) |
| 2016 |
Jan
(25) |
Feb
(30) |
Mar
(29) |
Apr
(10) |
May
(17) |
Jun
(1) |
Jul
(1) |
Aug
(6) |
Sep
(2) |
Oct
(1) |
Nov
(3) |
Dec
(2) |
| 2017 |
Jan
(5) |
Feb
(2) |
Mar
(7) |
Apr
(1) |
May
(7) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2018 |
Jan
|
Feb
|
Mar
(5) |
Apr
|
May
(1) |
Jun
|
Jul
(3) |
Aug
|
Sep
|
Oct
|
Nov
(2) |
Dec
|
| 2019 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(1) |
Dec
(3) |
| 2020 |
Jan
|
Feb
|
Mar
|
Apr
(6) |
May
|
Jun
|
Jul
(29) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2021 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(5) |
Dec
(3) |
| 2022 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(5) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
| 2023 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
(7) |
Jul
(1) |
Aug
|
Sep
(6) |
Oct
(4) |
Nov
(1) |
Dec
(4) |
| 2024 |
Jan
(2) |
Feb
(5) |
Mar
|
Apr
|
May
(8) |
Jun
(159) |
Jul
(90) |
Aug
(22) |
Sep
|
Oct
(6) |
Nov
(8) |
Dec
(1) |
| 2025 |
Jan
(20) |
Feb
(6) |
Mar
(2) |
Apr
(4) |
May
(29) |
Jun
(63) |
Jul
(62) |
Aug
(70) |
Sep
(120) |
Oct
(46) |
Nov
(33) |
Dec
(25) |
| 2026 |
Jan
(37) |
Feb
(56) |
Mar
(62) |
Apr
(64) |
May
(55) |
Jun
(38) |
Jul
(23) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: <joe...@us...> - 2003-01-21 18:16:16
|
Update of /cvsroot/nmock/nmock/test/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv16434/test/NMock/Constraints
Modified Files:
ConstraintsTest.cs
Log Message:
PropertyIs can now support properties of properties.... eg "Name.FirstName.Length"
Index: ConstraintsTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/Constraints/ConstraintsTest.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ConstraintsTest.cs 21 Jan 2003 17:36:00 -0000 1.3
--- ConstraintsTest.cs 21 Jan 2003 18:16:13 -0000 1.4
***************
*** 258,261 ****
--- 258,270 ----
}
+ [Test]
+ public void PropertyIsWithNestedProperties()
+ {
+ ThingWithProps t = new ThingWithProps();
+
+ Assertion.Assert(new PropertyIs("MyProp.Length", 5).Eval(t));
+ Assertion.Assert(!new PropertyIs("MyProp.Length", 9).Eval(t));
+ }
+
class ThingWithProps
{
|
|
From: <joe...@us...> - 2003-01-21 18:16:15
|
Update of /cvsroot/nmock/nmock/src/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv16434/src/NMock/Constraints
Modified Files:
Constraints.cs
Log Message:
PropertyIs can now support properties of properties.... eg "Name.FirstName.Length"
Index: Constraints.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Constraints/Constraints.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Constraints.cs 21 Jan 2003 17:36:00 -0000 1.4
--- Constraints.cs 21 Jan 2003 18:16:13 -0000 1.5
***************
*** 364,367 ****
--- 364,370 ----
/// This constraint decorates another constraint, allowing it to test
/// a property of the object, rather than the property itself.
+ ///
+ /// Properties of properties can be specified by using the
+ /// "Property.SubProperty" notation.
/// </summary>
public class PropertyIs : IConstraint
***************
*** 386,393 ****
return false;
}
Type type = val.GetType();
PropertyInfo propertyInfo = type.GetProperty(property);
! object propertyValue = propertyInfo.GetValue(val, null);
! return constraint.Eval(propertyValue);
}
--- 389,406 ----
return false;
}
+ // split "a.b.c" into "a", "b", "c"
+ object propertyValue = val;
+ foreach(string propertyBit in property.Split(new char[] {'.'}))
+ {
+ propertyValue = getProperty(propertyValue, propertyBit);
+ }
+ return constraint.Eval(propertyValue);
+ }
+
+ private object getProperty(object val, string property)
+ {
Type type = val.GetType();
PropertyInfo propertyInfo = type.GetProperty(property);
! return propertyInfo.GetValue(val, null);
}
|
|
From: <joe...@us...> - 2003-01-21 17:36:04
|
Update of /cvsroot/nmock/nmock/src/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv30252/src/NMock/Constraints
Modified Files:
Constraints.cs
Log Message:
Added PropertyIs decorator for constraints to allow a constraint to test the value of a property rather than the object itself.
Index: Constraints.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Constraints/Constraints.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Constraints.cs 31 Dec 2002 21:36:37 -0000 1.3
--- Constraints.cs 21 Jan 2003 17:36:00 -0000 1.4
***************
*** 2,5 ****
--- 2,6 ----
using System.Text;
using System.Text.RegularExpressions;
+ using System.Reflection;
namespace NMock.Constraints
***************
*** 357,360 ****
--- 358,398 ----
{
get { return "<" + expected + ">"; }
+ }
+ }
+
+ /// <summary>
+ /// This constraint decorates another constraint, allowing it to test
+ /// a property of the object, rather than the property itself.
+ /// </summary>
+ public class PropertyIs : IConstraint
+ {
+ private string property;
+ private IConstraint constraint;
+
+ public PropertyIs(string property, object expected)
+ {
+ this.property = property;
+ constraint = expected as IConstraint;
+ if (constraint == null)
+ {
+ constraint = new IsEqual(expected);
+ }
+ }
+
+ public bool Eval(object val)
+ {
+ if (val == null)
+ {
+ return false;
+ }
+ Type type = val.GetType();
+ PropertyInfo propertyInfo = type.GetProperty(property);
+ object propertyValue = propertyInfo.GetValue(val, null);
+ return constraint.Eval(propertyValue);
+ }
+
+ public string Message
+ {
+ get { return String.Format("Property {0}: {1}", property, constraint.Message); }
}
}
|
|
From: <joe...@us...> - 2003-01-21 17:36:04
|
Update of /cvsroot/nmock/nmock/test/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv30252/test/NMock/Constraints
Modified Files:
ConstraintsTest.cs
Log Message:
Added PropertyIs decorator for constraints to allow a constraint to test the value of a property rather than the object itself.
Index: ConstraintsTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/Constraints/ConstraintsTest.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ConstraintsTest.cs 31 Dec 2002 21:36:40 -0000 1.2
--- ConstraintsTest.cs 21 Jan 2003 17:36:00 -0000 1.3
***************
*** 235,238 ****
--- 235,270 ----
[Test]
+ public void PropertyIs()
+ {
+ ThingWithProps t = new ThingWithProps();
+
+ // test property equals a value
+ Assertion.Assert(new PropertyIs("MyProp", "hello").Eval(t));
+ Assertion.Assert(!new PropertyIs("MyProp", "bye").Eval(t));
+
+ // test property using another constraint
+ Assertion.Assert(new PropertyIs("MyProp", new IsMatch("ell")).Eval(t));
+ Assertion.Assert(!new PropertyIs("MyProp", new IsMatch("sfsl")).Eval(t));
+
+ Assertion.AssertEquals(
+ "Property MyProp: <x>",
+ new PropertyIs("MyProp", new IsEqual("x")).Message);
+ }
+
+ [Test]
+ public void PropertyIsWithNullValue()
+ {
+ Assertion.Assert(!new PropertyIs("Blah", new IsAnything()).Eval(null));
+ }
+
+ class ThingWithProps
+ {
+ public string MyProp
+ {
+ get { return "hello"; }
+ }
+ }
+
+ [Test]
public void CollectingConstraint()
{
|
|
From: <joe...@us...> - 2003-01-21 16:44:15
|
Update of /cvsroot/nmock/nmock/src/NMock
In directory sc8-pr-cvs1:/tmp/cvs-serv2740/src/NMock
Modified Files:
DynamicMock.cs
Log Message:
Dull formatting change
Index: DynamicMock.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/DynamicMock.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** DynamicMock.cs 3 Jan 2003 15:59:57 -0000 1.4
--- DynamicMock.cs 21 Jan 2003 16:44:08 -0000 1.5
***************
*** 14,20 ****
public DynamicMock(Type type) : this(type, null)
{
! ignore = new ArrayList();
Name = "Mock" + StripLeadingIifInterface(type);
! }
public DynamicMock(Type type, string name) : base(name)
--- 14,20 ----
public DynamicMock(Type type) : this(type, null)
{
! ignore = new ArrayList();
Name = "Mock" + StripLeadingIifInterface(type);
! }
public DynamicMock(Type type, string name) : base(name)
***************
*** 43,52 ****
}
! private string StripLeadingIifInterface(Type type) {
! string name = type.Name;
! return name.StartsWith("I") ? name.Substring(1) : name;
! }
! private void generate()
{
ClassGenerator cg = new ClassGenerator();
--- 43,53 ----
}
! private string StripLeadingIifInterface(Type type)
! {
! string name = type.Name;
! return name.StartsWith("I") ? name.Substring(1) : name;
! }
! private void generate()
{
ClassGenerator cg = new ClassGenerator();
|
|
From: <sm...@us...> - 2003-01-03 16:00:51
|
Update of /cvsroot/nmock/nmock/src/NMock/Dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv13198/src/NMock/Dynamic
Modified Files:
ClassGenerator.cs
Log Message:
Extracted MethodImplementor and BoxingOpCodes from ClassGenerator
Index: ClassGenerator.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Dynamic/ClassGenerator.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** ClassGenerator.cs 31 Dec 2002 21:36:38 -0000 1.5
--- ClassGenerator.cs 3 Jan 2003 16:00:47 -0000 1.6
***************
*** 9,13 ****
public class ClassGenerator
{
! private static IDictionary boxingOpCodes;
public virtual object Generate(Type type, IMock mock)
--- 9,14 ----
public class ClassGenerator
{
! private const System.Reflection.BindingFlags ALL_INSTANCE_METHODS
! = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
public virtual object Generate(Type type, IMock mock)
***************
*** 16,46 ****
}
! public virtual object Generate(Type type, IMock mock, IList methodsToIgnore)
! {
! methodsToIgnore.Add("Equals");
! methodsToIgnore.Add("ToString");
! TypeBuilder typeBuilder = getTypeBuilder("Mock" + type.Name, type);
! FieldBuilder mockFieldBuilder = typeBuilder.DefineField("underlyingMock", typeof(IMock), FieldAttributes.Public);
! MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
! foreach ( MethodInfo m in methods )
! {
! if (IsOverridable(m) && !methodsToIgnore.Contains(m.Name))
! {
! implementMethod(type, typeBuilder, m, mockFieldBuilder);
! }
! }
! Type proxyType = typeBuilder.CreateType();
! object result = Activator.CreateInstance(proxyType);
! FieldInfo underlyingMock = proxyType.GetField("underlyingMock");
! underlyingMock.SetValue(result, mock);
! return result;
! }
!
! private bool IsOverridable(MethodInfo m)
{
return (m.IsVirtual && ! m.IsFinal);
}
! private TypeBuilder getTypeBuilder(string name, Type originalType)
{
AppDomain appDomain = AppDomain.CurrentDomain;
--- 17,44 ----
}
! public virtual object Generate(Type type, IMock mock, IList methodsToIgnore)
! {
! methodsToIgnore.Add("Equals");
! methodsToIgnore.Add("ToString");
!
! TypeBuilder typeBuilder = GetTypeBuilder("Mock" + type.Name, type);
! MethodImplementor methodImplementor = new MethodImplementor(typeBuilder);
!
! foreach ( MethodInfo methodInfo in type.GetMethods(ALL_INSTANCE_METHODS) )
! {
! if (IsOverridable(methodInfo) && !methodsToIgnore.Contains(methodInfo.Name))
! {
! methodImplementor.Implement(methodInfo);
! }
! }
! return CreateProxyInstance(typeBuilder, mock);
! }
!
! bool IsOverridable(MethodInfo m)
{
return (m.IsVirtual && ! m.IsFinal);
}
! TypeBuilder GetTypeBuilder(string name, Type originalType)
{
AppDomain appDomain = AppDomain.CurrentDomain;
***************
*** 64,170 ****
}
! private void implementMethod(Type type, TypeBuilder typeBuilder, MethodInfo m, FieldBuilder mockFieldBuilder)
! {
! Type returnType = m.ReturnType;
! ArrayList types = new ArrayList();
! foreach (ParameterInfo param in m.GetParameters())
! {
! types.Add(param.ParameterType);
! }
! Type[] paramTypes = (Type[])types.ToArray(typeof(Type));
! MethodBuilder methodBuilder = typeBuilder.DefineMethod(m.Name, MethodAttributes.Public | MethodAttributes.Virtual, returnType, paramTypes);
!
! ILGenerator il = methodBuilder.GetILGenerator();
! foreach (ParameterInfo param in m.GetParameters())
! {
! il.DeclareLocal(param.ParameterType);
! }
!
! string methodName = m.Name;
! if (methodName.StartsWith("get_") || methodName.StartsWith("set_"))
! {
! methodName = methodName.Substring(4);
! }
! il.Emit(OpCodes.Ldarg_0);
! il.Emit(OpCodes.Ldfld, mockFieldBuilder);
! il.Emit(OpCodes.Ldstr, methodName);
! il.Emit(OpCodes.Ldc_I4_S, paramTypes.Length);
! il.Emit(OpCodes.Newarr, typeof(object));
! if (paramTypes.Length > 0)
! {
! il.Emit(OpCodes.Stloc_0);
! il.Emit(OpCodes.Ldloc_0);
! for(int i = 0; i < paramTypes.Length; i++)
! {
! il.Emit(OpCodes.Ldc_I4_S, i);
! il.Emit(OpCodes.Ldarg_S, i + 1);
! if (paramTypes[i].IsPrimitive)
! {
! il.Emit(OpCodes.Box, paramTypes[i]);
! }
! il.Emit(OpCodes.Stelem_Ref);
! il.Emit(OpCodes.Ldloc_0);
! }
! }
! MethodInfo call = typeof(IMock).GetMethod("Call");
! il.EmitCall(OpCodes.Callvirt, call, null);
! if (returnType == typeof(void))
! {
! il.Emit(OpCodes.Pop);
! }
! else
! {
! if (returnType.IsPrimitive)
! {
! il.Emit(OpCodes.Unbox, returnType);
! il.Emit(getBoxingOpCode(returnType));
! }
! il.DeclareLocal(returnType);
! il.Emit(OpCodes.Stloc_0);
! Label l = il.DefineLabel();
! il.Emit(OpCodes.Br_S, l);
! il.MarkLabel(l);
! il.Emit(OpCodes.Ldloc_0);
! }
! il.Emit(OpCodes.Ret);
! }
! public OpCode getBoxingOpCode( Type aType )
! {
! if (boxingOpCodes == null)
! {
! boxingOpCodes = new Hashtable();
! boxingOpCodes[typeof(sbyte)] = OpCodes.Ldind_I1;
! boxingOpCodes[typeof(short)] = OpCodes.Ldind_I2;
! boxingOpCodes[typeof(int)] = OpCodes.Ldind_I4;
! boxingOpCodes[typeof(long)] = OpCodes.Ldind_I8;
! boxingOpCodes[typeof(byte)] = OpCodes.Ldind_U1;
! boxingOpCodes[typeof(ushort)] = OpCodes.Ldind_U2;
! boxingOpCodes[typeof(uint)] = OpCodes.Ldind_U4;
! boxingOpCodes[typeof(ulong)] = OpCodes.Ldind_I8;
! boxingOpCodes[typeof(float)] = OpCodes.Ldind_R4;
! boxingOpCodes[typeof(double)] = OpCodes.Ldind_R8;
! boxingOpCodes[typeof(char)] = OpCodes.Ldind_U2;
! boxingOpCodes[typeof(bool)] = OpCodes.Ldind_I1;
! }
! if (boxingOpCodes.Contains(aType))
! {
! return (OpCode)boxingOpCodes[aType];
! }
! else
! {
! return OpCodes.Ldind_I1;
! }
! }
! }
!
!
}
--- 62,233 ----
}
! object CreateProxyInstance(TypeBuilder typeBuilder, IMock mock)
! {
! Type proxyType = typeBuilder.CreateType();
! object result = Activator.CreateInstance(proxyType);
! FieldInfo underlyingMock = proxyType.GetField("underlyingMock");
! underlyingMock.SetValue(result, mock);
!
! return result;
! }
!
! }
!
! public class MethodImplementor
! {
! private BoxingOpCodes boxingOpCodes = new BoxingOpCodes();
! private TypeBuilder typeBuilder;
! private FieldBuilder mockFieldBuilder;
!
! public MethodImplementor(TypeBuilder aTypeBuilder)
! {
! typeBuilder = aTypeBuilder;
! mockFieldBuilder = typeBuilder.DefineField("underlyingMock", typeof(IMock), FieldAttributes.Public);
! }
!
! public virtual void Implement(MethodInfo methodInfo)
! {
! Type returnType = methodInfo.ReturnType;
! ParameterInfo[] parameterInfo = methodInfo.GetParameters();
! Type[] paramTypes = ExtractParameterTypes(parameterInfo);
! ILGenerator il = CreateILGenerator(methodInfo, returnType, paramTypes);
!
! EmitMethodSignature(methodInfo, paramTypes, il);
! EmitMethodCall(il);
! EmitMethodReturn(returnType, il);
! }
!
! private Type[] ExtractParameterTypes(ParameterInfo[] parameters)
! {
! Type[] paramTypes = new Type[parameters.Length];
! for (int i = 0; i < parameters.Length; ++i)
! {
! paramTypes[i] = parameters[i].ParameterType;
! }
! return paramTypes;
! }
!
! private ILGenerator CreateILGenerator(MethodInfo methodInfo, Type returnType, Type[] paramTypes)
! {
! MethodBuilder methodBuilder =
! typeBuilder.DefineMethod(methodInfo.Name, MethodAttributes.Public | MethodAttributes.Virtual, returnType, paramTypes);
!
! return methodBuilder.GetILGenerator();
! }
!
! private void EmitMethodSignature(MethodInfo methodInfo, Type[] paramTypes, ILGenerator il)
! {
! foreach (Type paramType in paramTypes)
! {
! il.DeclareLocal(paramType);
! }
! il.Emit(OpCodes.Ldarg_0);
! il.Emit(OpCodes.Ldfld, mockFieldBuilder);
! il.Emit(OpCodes.Ldstr, StripGetSetPrefix(methodInfo));
! il.Emit(OpCodes.Ldc_I4_S, paramTypes.Length);
! il.Emit(OpCodes.Newarr, typeof(object));
! if (paramTypes.Length > 0)
! {
! il.Emit(OpCodes.Stloc_0);
! il.Emit(OpCodes.Ldloc_0);
! for(int i = 0; i < paramTypes.Length; i++)
! {
! il.Emit(OpCodes.Ldc_I4_S, i);
! il.Emit(OpCodes.Ldarg_S, i + 1);
! if (paramTypes[i].IsPrimitive)
! {
! il.Emit(OpCodes.Box, paramTypes[i]);
! }
! il.Emit(OpCodes.Stelem_Ref);
! il.Emit(OpCodes.Ldloc_0);
! }
! }
! }
!
! private void EmitMethodCall(ILGenerator il)
! {
! MethodInfo call = typeof(IMock).GetMethod("Call");
! il.EmitCall(OpCodes.Callvirt, call, null);
! }
! private void EmitMethodReturn(Type returnType, ILGenerator il)
! {
! if (returnType == typeof(void))
! {
! il.Emit(OpCodes.Pop);
! }
! else
! {
! if (returnType.IsPrimitive)
! {
! il.Emit(OpCodes.Unbox, returnType);
! il.Emit(boxingOpCodes[returnType]);
! }
! il.DeclareLocal(returnType);
! il.Emit(OpCodes.Stloc_0);
! Label l = il.DefineLabel();
! il.Emit(OpCodes.Br_S, l);
! il.MarkLabel(l);
! il.Emit(OpCodes.Ldloc_0);
! }
! il.Emit(OpCodes.Ret);
! }
! private string StripGetSetPrefix(MethodInfo methodInfo)
! {
! string methodName;
! methodName = methodInfo.Name;
! if (methodName.StartsWith("get_") || methodName.StartsWith("set_"))
! {
! methodName = methodName.Substring(4);
! }
! return methodName;
! }
! }
! public class BoxingOpCodes
! {
! private static IDictionary boxingOpCodes;
! public OpCode this[Type aType]
! {
! get
! {
! return GetOpCode(aType);
! }
! }
!
! private static OpCode GetOpCode( Type aType )
! {
! if (boxingOpCodes == null)
! {
! boxingOpCodes = new Hashtable();
! boxingOpCodes[typeof(sbyte)] = OpCodes.Ldind_I1;
! boxingOpCodes[typeof(short)] = OpCodes.Ldind_I2;
! boxingOpCodes[typeof(int)] = OpCodes.Ldind_I4;
! boxingOpCodes[typeof(long)] = OpCodes.Ldind_I8;
! boxingOpCodes[typeof(byte)] = OpCodes.Ldind_U1;
! boxingOpCodes[typeof(ushort)] = OpCodes.Ldind_U2;
! boxingOpCodes[typeof(uint)] = OpCodes.Ldind_U4;
! boxingOpCodes[typeof(ulong)] = OpCodes.Ldind_I8;
! boxingOpCodes[typeof(float)] = OpCodes.Ldind_R4;
! boxingOpCodes[typeof(double)] = OpCodes.Ldind_R8;
! boxingOpCodes[typeof(char)] = OpCodes.Ldind_U2;
! boxingOpCodes[typeof(bool)] = OpCodes.Ldind_I1;
! }
! if (boxingOpCodes.Contains(aType))
! {
! return (OpCode)boxingOpCodes[aType];
! }
! else
! {
! return OpCodes.Ldind_I1;
! }
! }
! }
}
|
|
From: <sm...@us...> - 2003-01-03 16:00:50
|
Update of /cvsroot/nmock/nmock/test/NMock/Dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv13198/test/NMock/Dynamic
Modified Files:
ClassGeneratorTest.cs
Log Message:
Extracted MethodImplementor and BoxingOpCodes from ClassGenerator
Index: ClassGeneratorTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/Dynamic/ClassGeneratorTest.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ClassGeneratorTest.cs 31 Dec 2002 21:36:40 -0000 1.4
--- ClassGeneratorTest.cs 3 Jan 2003 16:00:46 -0000 1.5
***************
*** 257,274 ****
[Test]
! public void BoxingOpCodes()
{
! Assertion.AssertEquals( OpCodes.Ldind_I1, cg.getBoxingOpCode(typeof(sbyte)) );
! Assertion.AssertEquals( OpCodes.Ldind_I2, cg.getBoxingOpCode(typeof(short)) );
! Assertion.AssertEquals( OpCodes.Ldind_I4, cg.getBoxingOpCode(typeof(int)) );
! Assertion.AssertEquals( OpCodes.Ldind_I8, cg.getBoxingOpCode(typeof(long)) );
! Assertion.AssertEquals( OpCodes.Ldind_U1, cg.getBoxingOpCode(typeof(byte)) );
! Assertion.AssertEquals( OpCodes.Ldind_U2, cg.getBoxingOpCode(typeof(ushort)) );
! Assertion.AssertEquals( OpCodes.Ldind_U4, cg.getBoxingOpCode(typeof(uint)) );
! Assertion.AssertEquals( OpCodes.Ldind_I8, cg.getBoxingOpCode(typeof(ulong)) );
! Assertion.AssertEquals( OpCodes.Ldind_R4, cg.getBoxingOpCode(typeof(float)) );
! Assertion.AssertEquals( OpCodes.Ldind_R8, cg.getBoxingOpCode(typeof(double)) );
! Assertion.AssertEquals( OpCodes.Ldind_U2, cg.getBoxingOpCode(typeof(char)) );
! Assertion.AssertEquals( OpCodes.Ldind_I1, cg.getBoxingOpCode(typeof(bool)) );
}
--- 257,276 ----
[Test]
! public void CheckBoxingOpCodes()
{
! BoxingOpCodes opCodes = new BoxingOpCodes();
!
! Assertion.AssertEquals( OpCodes.Ldind_I1, opCodes[typeof(sbyte)] );
! Assertion.AssertEquals( OpCodes.Ldind_I2, opCodes[typeof(short)] );
! Assertion.AssertEquals( OpCodes.Ldind_I4, opCodes[typeof(int)] );
! Assertion.AssertEquals( OpCodes.Ldind_I8, opCodes[typeof(long)] );
! Assertion.AssertEquals( OpCodes.Ldind_U1, opCodes[typeof(byte)] );
! Assertion.AssertEquals( OpCodes.Ldind_U2, opCodes[typeof(ushort)] );
! Assertion.AssertEquals( OpCodes.Ldind_U4, opCodes[typeof(uint)] );
! Assertion.AssertEquals( OpCodes.Ldind_I8, opCodes[typeof(ulong)] );
! Assertion.AssertEquals( OpCodes.Ldind_R4, opCodes[typeof(float)] );
! Assertion.AssertEquals( OpCodes.Ldind_R8, opCodes[typeof(double)] );
! Assertion.AssertEquals( OpCodes.Ldind_U2, opCodes[typeof(char)] );
! Assertion.AssertEquals( OpCodes.Ldind_I1, opCodes[typeof(bool)] );
}
|
|
From: <sm...@us...> - 2003-01-03 16:00:08
|
Update of /cvsroot/nmock/nmock/src/NMock
In directory sc8-pr-cvs1:/tmp/cvs-serv12763/src/NMock
Modified Files:
DynamicMock.cs
Log Message:
Extracted method for stripping leading 'I'
Index: DynamicMock.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/DynamicMock.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** DynamicMock.cs 15 Nov 2002 22:31:09 -0000 1.3
--- DynamicMock.cs 3 Jan 2003 15:59:57 -0000 1.4
***************
*** 14,26 ****
public DynamicMock(Type type) : this(type, null)
{
! string name = type.Name;
! ignore = new ArrayList();
! if (name.StartsWith("I"))
! {
! name = name.Substring(1);
! }
! Name = "Mock" + name;
! }
!
public DynamicMock(Type type, string name) : base(name)
{
--- 14,21 ----
public DynamicMock(Type type) : this(type, null)
{
! ignore = new ArrayList();
! Name = "Mock" + StripLeadingIifInterface(type);
! }
!
public DynamicMock(Type type, string name) : base(name)
{
***************
*** 48,52 ****
}
! private void generate()
{
ClassGenerator cg = new ClassGenerator();
--- 43,52 ----
}
! private string StripLeadingIifInterface(Type type) {
! string name = type.Name;
! return name.StartsWith("I") ? name.Substring(1) : name;
! }
!
! private void generate()
{
ClassGenerator cg = new ClassGenerator();
|
|
From: <exo...@us...> - 2002-12-31 21:37:11
|
Update of /cvsroot/nmock/nmock/src/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv31302/src/NMock/Constraints
Modified Files:
Constraints.cs
Log Message:
modified nant build file to build separate core and test assemblies
added new CollectingConstraint for post-test parameter validation
modified ClassGenerator to support overriding of internal and protected internal methods
fixed exception message in MockCall.checkArguments
Index: Constraints.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Constraints/Constraints.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** Constraints.cs 12 Dec 2002 21:42:35 -0000 1.2
--- Constraints.cs 31 Dec 2002 21:36:37 -0000 1.3
***************
*** 381,383 ****
--- 381,404 ----
}
+
+ public class CollectingConstraint : IConstraint
+ {
+ private object parameter;
+
+ public object Parameter
+ {
+ get { return parameter; }
+ }
+
+ public bool Eval(object val)
+ {
+ parameter = val;
+ return true;
+ }
+
+ public string Message
+ {
+ get { return "Collecting Constraint"; }
+ }
+ }
}
|
|
From: <exo...@us...> - 2002-12-31 21:37:10
|
Update of /cvsroot/nmock/nmock
In directory sc8-pr-cvs1:/tmp/cvs-serv31302
Modified Files:
nmock.build nmock.suo
Log Message:
modified nant build file to build separate core and test assemblies
added new CollectingConstraint for post-test parameter validation
modified ClassGenerator to support overriding of internal and protected internal methods
fixed exception message in MockCall.checkArguments
Index: nmock.build
===================================================================
RCS file: /cvsroot/nmock/nmock/nmock.build,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** nmock.build 14 Dec 2002 21:28:09 -0000 1.2
--- nmock.build 31 Dec 2002 21:36:37 -0000 1.3
***************
*** 1,24 ****
<project name="NMock" default="release">
! <property name="nunit.output" value="Plain"/>
! <target name="compile" description="Compile core library">
<mkdir dir="build"/>
<csc target="library" output="build/nmock.dll" debug="true">
<sources>
<includes name="src/**.cs"/>
<includes name="test/**.cs"/>
<includes name="sample/**.cs"/>
</sources>
! <references basedir="lib">
! <includes name="*.dll"/>
</references>
</csc>
<copy file="lib\nunit.framework.dll" todir="build" />
! </target>
!
<target name="test" depends="compile" description="Run unit tests">
<nunit2>
! <test assemblyname="build\nmock.dll" fork="true" type="${nunit.output}"/>
</nunit2>
</target>
--- 1,41 ----
<project name="NMock" default="release">
! <property name="nunit.output" value="Plain"/>
! <target name="init">
<mkdir dir="build"/>
+ </target>
+
+ <target name="compile" description="Compiles all assemblies" depends="init">
+ <call target="compile.core"/>
+ <call target="compile.test"/>
+ </target>
+
+ <target name="compile.core" description="Compiles core assembly" depends="init">
<csc target="library" output="build/nmock.dll" debug="true">
<sources>
<includes name="src/**.cs"/>
+ </sources>
+ </csc>
+ </target>
+
+ <target name="compile.test" description="Compiles core assembly" depends="compile.core">
+ <csc target="library" output="build/nmock.test.dll" debug="true">
+ <sources>
<includes name="test/**.cs"/>
<includes name="sample/**.cs"/>
</sources>
! <references>
! <includes name="build/nmock.dll"/>
! <includes name="lib/*.dll"/>
</references>
+ <arg value="/nowarn:0679,1591"/>
</csc>
<copy file="lib\nunit.framework.dll" todir="build" />
! </target>
!
<target name="test" depends="compile" description="Run unit tests">
<nunit2>
! <test assemblyname="build\nmock.test.dll" fork="true" type="${nunit.output}"/>
</nunit2>
</target>
Index: nmock.suo
===================================================================
RCS file: /cvsroot/nmock/nmock/nmock.suo,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
Binary files /tmp/cvsrV3qy9 and /tmp/cvsqBLqV8 differ
|
|
From: <exo...@us...> - 2002-12-31 21:36:44
|
Update of /cvsroot/nmock/nmock/test
In directory sc8-pr-cvs1:/tmp/cvs-serv31302/test
Modified Files:
test.csproj.user
Log Message:
modified nant build file to build separate core and test assemblies
added new CollectingConstraint for post-test parameter validation
modified ClassGenerator to support overriding of internal and protected internal methods
fixed exception message in MockCall.checkArguments
Index: test.csproj.user
===================================================================
RCS file: /cvsroot/nmock/nmock/test/test.csproj.user,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** test.csproj.user 16 Dec 2002 14:52:41 -0000 1.1
--- test.csproj.user 31 Dec 2002 21:36:40 -0000 1.2
***************
*** 2,6 ****
<CSHARP>
<Build>
! <Settings ReferencePath = "D:\Projects\nmock\lib\" >
<Config
Name = "Debug"
--- 2,6 ----
<CSHARP>
<Build>
! <Settings ReferencePath = "D:\Projects\nmock\lib\;C:\dev\nmock\lib\" >
<Config
Name = "Debug"
|
|
From: <exo...@us...> - 2002-12-31 21:36:44
|
Update of /cvsroot/nmock/nmock/test/NMock/Dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv31302/test/NMock/Dynamic
Modified Files:
ClassGeneratorTest.cs
Log Message:
modified nant build file to build separate core and test assemblies
added new CollectingConstraint for post-test parameter validation
modified ClassGenerator to support overriding of internal and protected internal methods
fixed exception message in MockCall.checkArguments
Index: ClassGeneratorTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/Dynamic/ClassGeneratorTest.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ClassGeneratorTest.cs 12 Dec 2002 21:39:44 -0000 1.3
--- ClassGeneratorTest.cs 31 Dec 2002 21:36:40 -0000 1.4
***************
*** 29,49 ****
}
! public abstract class SolidThingy
{
public virtual string VirtualMethod() { return "xx"; }
- public override string ToString() { return "xx"; }
public abstract string AbstractMethod();
// cannot override
public static string StaticMethod() { return "xx"; }
public string NonVirtualMethod() { return "xx"; }
private string privateMethod() { return "xx"; }
- internal string internalMethod() { return "xx"; }
protected virtual string protectedMethod() { return "xx"; }
- protected internal virtual string protectedInternalMethod() { return "xx"; }
string defaultInternalMethod() { return "xx"; }
!
}
!
[TestFixture]
public class ClassGeneratorTest
--- 29,61 ----
}
! public interface ISolidThingy
! {
! string NonVirtualProperty { get; }
! }
!
! // internal and protected internal methods must be overridable!
! public abstract class SolidThingy : ISolidThingy
{
public virtual string VirtualMethod() { return "xx"; }
public abstract string AbstractMethod();
+ internal virtual string InternalMethod() { return "xx"; }
+ protected internal virtual string ProtectedInternalMethod() { return "xx"; }
// cannot override
public static string StaticMethod() { return "xx"; }
public string NonVirtualMethod() { return "xx"; }
+ internal string NonVirtualInternalMethod() { return "xx"; }
private string privateMethod() { return "xx"; }
protected virtual string protectedMethod() { return "xx"; }
string defaultInternalMethod() { return "xx"; }
! public override string ToString() { return "xx"; } // method is ignored
!
! // implemented interface members/methods are defined as final (ie. non-virtual)
! public string NonVirtualProperty
! {
! get { return "xx"; }
! }
}
!
[TestFixture]
public class ClassGeneratorTest
***************
*** 229,237 ****
--- 241,256 ----
mock.ExpectAndReturn("GetHashCode", 123);
mock.ExpectAndReturn("AbstractMethod", "fish");
+ mock.ExpectAndReturn("InternalMethod", "black");
+ mock.ExpectAndReturn("ProtectedInternalMethod", "white");
+
Assertion.AssertEquals("hello", s.VirtualMethod());
Assertion.AssertEquals(123, s.GetHashCode());
Assertion.AssertEquals("fish", s.AbstractMethod());
+ Assertion.AssertEquals("black", s.InternalMethod());
+ Assertion.AssertEquals("white", s.ProtectedInternalMethod());
Assertion.AssertEquals("xx", s.NonVirtualMethod());
+ Assertion.AssertEquals("xx", s.NonVirtualProperty);
+ Assertion.AssertEquals("xx", s.ToString());
mock.Verify();
}
|
|
From: <exo...@us...> - 2002-12-31 21:36:43
|
Update of /cvsroot/nmock/nmock/test/NMock/Constraints
In directory sc8-pr-cvs1:/tmp/cvs-serv31302/test/NMock/Constraints
Modified Files:
ConstraintsTest.cs
Log Message:
modified nant build file to build separate core and test assemblies
added new CollectingConstraint for post-test parameter validation
modified ClassGenerator to support overriding of internal and protected internal methods
fixed exception message in MockCall.checkArguments
Index: ConstraintsTest.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/NMock/Constraints/ConstraintsTest.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** ConstraintsTest.cs 15 Nov 2002 22:48:20 -0000 1.1
--- ConstraintsTest.cs 31 Dec 2002 21:36:40 -0000 1.2
***************
*** 235,238 ****
--- 235,250 ----
[Test]
+ public void CollectingConstraint()
+ {
+ CollectingConstraint c = new CollectingConstraint();
+ Assertion.Assert(c.Eval("test"));
+ Assertion.AssertEquals("test", c.Parameter);
+
+ Assertion.Assert("eval should always be true", c.Eval(null));
+ Assertion.AssertNull(c.Parameter);
+
+ }
+
+ [Test]
public void Delegate()
{
|
|
From: <exo...@us...> - 2002-12-31 21:36:43
|
Update of /cvsroot/nmock/nmock/src/NMock
In directory sc8-pr-cvs1:/tmp/cvs-serv31302/src/NMock
Modified Files:
MockCall.cs
Log Message:
modified nant build file to build separate core and test assemblies
added new CollectingConstraint for post-test parameter validation
modified ClassGenerator to support overriding of internal and protected internal methods
fixed exception message in MockCall.checkArguments
Index: MockCall.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/MockCall.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** MockCall.cs 16 Dec 2002 14:49:51 -0000 1.1
--- MockCall.cs 31 Dec 2002 21:36:39 -0000 1.2
***************
*** 63,67 ****
if ( HasExpectations )
{
! Mock.Assertion.AssertEquals("x() called with incorrect number of parameters",
expectedArgs.Length, actualArgs.Length);
--- 63,67 ----
if ( HasExpectations )
{
! Mock.Assertion.AssertEquals(methodName + "() called with incorrect number of parameters",
expectedArgs.Length, actualArgs.Length);
|
|
From: <exo...@us...> - 2002-12-31 21:36:42
|
Update of /cvsroot/nmock/nmock/src/NMock/Dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv31302/src/NMock/Dynamic
Modified Files:
ClassGenerator.cs
Log Message:
modified nant build file to build separate core and test assemblies
added new CollectingConstraint for post-test parameter validation
modified ClassGenerator to support overriding of internal and protected internal methods
fixed exception message in MockCall.checkArguments
Index: ClassGenerator.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Dynamic/ClassGenerator.cs,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ClassGenerator.cs 16 Dec 2002 14:48:49 -0000 1.4
--- ClassGenerator.cs 31 Dec 2002 21:36:38 -0000 1.5
***************
*** 25,29 ****
foreach ( MethodInfo m in methods )
{
! if(!methodsToIgnore.Contains(m.Name))
{
implementMethod(type, typeBuilder, m, mockFieldBuilder);
--- 25,29 ----
foreach ( MethodInfo m in methods )
{
! if (IsOverridable(m) && !methodsToIgnore.Contains(m.Name))
{
implementMethod(type, typeBuilder, m, mockFieldBuilder);
***************
*** 37,40 ****
--- 37,45 ----
}
+ private bool IsOverridable(MethodInfo m)
+ {
+ return (m.IsVirtual && ! m.IsFinal);
+ }
+
private TypeBuilder getTypeBuilder(string name, Type originalType)
{
|
|
From: Joe W. <jo...@tr...> - 2002-12-16 17:57:39
|
Steve: >>> Why not? It seems a bit odd to write another >>> assertion class Joe: >>Two reasons: >> >> 1) I haven't quite figured out how assembly linking works in .NET yet. >> If NMock is compiled for version x of NUnit and then the user attempts >> to use it with version y, it fails miserably. I'm sure there's a nice >> solution though... >> >> 2) There are lots of other unit-testing frameworks for .NET (NUnit 1, >> NUnit 2 which is totally different, X-Unity, #Unit, blah blah). Didn't >> want to tie the user into a particular tool. Steve: > Interesting, the monolithic MS world is far more splintered than for > other languages. Unfortunately NUnit 1.0 was a bit of a balls up (it was a direct port line for line of JUnit which didn't make the most of .NET). So lots of other people started writing alternatives that were better. Then NUnit 2.0 came out (recently) which kind of won, but there are still lots of people use other tools. > I think it may be worth thinking this one through a bit, because it > just feels wrong to start yet another assertion library. Agree. Any ideas? I was thinking about making an abstraction over the other apis, but compared with writing a very simple class it just didnt make sense. > Also, > - I'm not sure that the default behaviour for a null argument should be to match > anything. That makes it a right pain to test for equality with nulls. We can > have another marker for ignore all arguments. Well, there is the IsNull contstraint. I found I used IsAnything alot more than IsNull so I made it a default. However it's obviously confusing. Would like to get more people's opinions on this... > - we might want to add a return value on the mock call. I think we did this > in the Java version with a default value to fall back to. Yup. It's on the todo list: http://jira.truemesh.com/secure/ViewIssue.jspa?key=NMO-2 >I'll see if I can get checkin the new stuff. Too late!!! :) -Joe PS. See the roadmap: http://jira.truemesh.com/secure/BrowseProject.jspa?id=10001&report=roadmap |
|
From: <sm...@us...> - 2002-12-16 15:05:03
|
Update of /cvsroot/nmock/nmock/test
In directory sc8-pr-cvs1:/tmp/cvs-serv20035/test
Modified Files:
AssemblyInfo.cs
Log Message:
Turned off most of the AssemblyInfo to get through the build.
Index: AssemblyInfo.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/test/AssemblyInfo.cs,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AssemblyInfo.cs 16 Dec 2002 14:52:31 -0000 1.1
--- AssemblyInfo.cs 16 Dec 2002 15:04:48 -0000 1.2
***************
*** 7,18 ****
// associated with an assembly.
//
! [assembly: AssemblyTitle("")]
! [assembly: AssemblyDescription("")]
! [assembly: AssemblyConfiguration("")]
! [assembly: AssemblyCompany("")]
! [assembly: AssemblyProduct("")]
! [assembly: AssemblyCopyright("")]
! [assembly: AssemblyTrademark("")]
! [assembly: AssemblyCulture("")]
//
--- 7,18 ----
// associated with an assembly.
//
! // [assembly: AssemblyTitle("NMock tests")]
! // [assembly: AssemblyDescription("")]
! // [assembly: AssemblyConfiguration("")]
! // [assembly: AssemblyCompany("truemesh.com")]
! // [assembly: AssemblyProduct("")]
! // [assembly: AssemblyCopyright("")]
! // [assembly: AssemblyTrademark("")]
! // [assembly: AssemblyCulture("")]
//
***************
*** 27,31 ****
// by using the '*' as shown below:
! [assembly: AssemblyVersion("1.0.*")]
//
--- 27,31 ----
// by using the '*' as shown below:
! // [assembly: AssemblyVersion("1.0.*")]
//
***************
*** 54,58 ****
// documentation for more information on this.
//
! [assembly: AssemblyDelaySign(false)]
! [assembly: AssemblyKeyFile("")]
! [assembly: AssemblyKeyName("")]
--- 54,58 ----
// documentation for more information on this.
//
! // [assembly: AssemblyDelaySign(false)]
! // [assembly: AssemblyKeyFile("")]
! // [assembly: AssemblyKeyName("")]
|
|
From: <sm...@us...> - 2002-12-16 14:53:41
|
Update of /cvsroot/nmock/nmock
In directory sc8-pr-cvs1:/tmp/cvs-serv16131
Added Files:
nmock.suo nmock.sln
Log Message:
Added VisualStudio noise
--- NEW FILE: nmock.suo ---
(This appears to be a binary file; contents omitted.)
--- NEW FILE: nmock.sln ---
Microsoft Visual Studio Solution File, Format Version 7.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "src", "src\src.csproj", "{4859B9E5-3F65-4517-878C-AFC58B9D0035}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "test", "test\test.csproj", "{2735C01B-475D-4B75-AF30-C00D9A977E58}"
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
ConfigName.0 = Debug
ConfigName.1 = Release
EndGlobalSection
GlobalSection(ProjectDependencies) = postSolution
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{4859B9E5-3F65-4517-878C-AFC58B9D0035}.Debug.ActiveCfg = Debug|.NET
{4859B9E5-3F65-4517-878C-AFC58B9D0035}.Debug.Build.0 = Debug|.NET
{4859B9E5-3F65-4517-878C-AFC58B9D0035}.Release.ActiveCfg = Release|.NET
{4859B9E5-3F65-4517-878C-AFC58B9D0035}.Release.Build.0 = Release|.NET
{2735C01B-475D-4B75-AF30-C00D9A977E58}.Debug.ActiveCfg = Debug|.NET
{2735C01B-475D-4B75-AF30-C00D9A977E58}.Debug.Build.0 = Debug|.NET
{2735C01B-475D-4B75-AF30-C00D9A977E58}.Release.ActiveCfg = Release|.NET
{2735C01B-475D-4B75-AF30-C00D9A977E58}.Release.Build.0 = Release|.NET
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal
|
|
From: <sm...@us...> - 2002-12-16 14:52:45
|
Update of /cvsroot/nmock/nmock/test
In directory sc8-pr-cvs1:/tmp/cvs-serv15699/test
Added Files:
test.csproj AssemblyInfo.cs test.csproj.user
Log Message:
Added VisualStudio noise
--- NEW FILE: test.csproj ---
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.0.9466"
SchemaVersion = "1.0"
ProjectGuid = "{2735C01B-475D-4B75-AF30-C00D9A977E58}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "test"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
RootNamespace = "NMock"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.dll"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.XML"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"
/>
<Reference
Name = "src"
Project = "{4859B9E5-3F65-4517-878C-AFC58B9D0035}"
Package = "{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}"
/>
<Reference
Name = "nunit.util"
AssemblyName = "nunit.util"
HintPath = "..\lib\nunit.util.dll"
/>
<Reference
Name = "nunit.framework"
AssemblyName = "nunit.framework"
HintPath = "..\lib\nunit.framework.dll"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\DynamicMockTest.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\MockTest.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\VerifyExceptionTest.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\Constraints\ConstraintsTest.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\Dynamic\ClassGeneratorTest.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>
--- NEW FILE: AssemblyInfo.cs ---
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]
--- NEW FILE: test.csproj.user ---
<VisualStudioProject>
<CSHARP>
<Build>
<Settings ReferencePath = "D:\Projects\nmock\lib\" >
<Config
Name = "Debug"
EnableASPDebugging = "false"
EnableASPXDebugging = "false"
EnableUnmanagedDebugging = "false"
EnableSQLServerDebugging = "false"
RemoteDebugEnabled = "false"
RemoteDebugMachine = ""
StartAction = "Project"
StartArguments = ""
StartPage = ""
StartProgram = ""
StartURL = ""
StartWorkingDirectory = ""
StartWithIE = "false"
/>
<Config
Name = "Release"
EnableASPDebugging = "false"
EnableASPXDebugging = "false"
EnableUnmanagedDebugging = "false"
EnableSQLServerDebugging = "false"
RemoteDebugEnabled = "false"
RemoteDebugMachine = ""
StartAction = "Project"
StartArguments = ""
StartPage = ""
StartProgram = ""
StartURL = ""
StartWorkingDirectory = ""
StartWithIE = "false"
/>
</Settings>
</Build>
<OtherProjectSettings
CopyProjectDestinationFolder = ""
CopyProjectUncPath = ""
CopyProjectOption = "0"
ProjectView = "ProjectFiles"
ProjectTrust = "0"
/>
</CSHARP>
</VisualStudioProject>
|
|
From: <sm...@us...> - 2002-12-16 14:51:34
|
Update of /cvsroot/nmock/nmock/src
In directory sc8-pr-cvs1:/tmp/cvs-serv15228/src
Added Files:
src.csproj.user src.csproj AssemblyInfo.cs
Log Message:
Added VisualStudio noise
--- NEW FILE: src.csproj.user ---
<VisualStudioProject>
<CSHARP>
<Build>
<Settings ReferencePath = "" >
<Config
Name = "Debug"
EnableASPDebugging = "false"
EnableASPXDebugging = "false"
EnableUnmanagedDebugging = "false"
EnableSQLServerDebugging = "false"
RemoteDebugEnabled = "false"
RemoteDebugMachine = ""
StartAction = "Project"
StartArguments = ""
StartPage = ""
StartProgram = ""
StartURL = ""
StartWorkingDirectory = ""
StartWithIE = "false"
/>
<Config
Name = "Release"
EnableASPDebugging = "false"
EnableASPXDebugging = "false"
EnableUnmanagedDebugging = "false"
EnableSQLServerDebugging = "false"
RemoteDebugEnabled = "false"
RemoteDebugMachine = ""
StartAction = "Project"
StartArguments = ""
StartPage = ""
StartProgram = ""
StartURL = ""
StartWorkingDirectory = ""
StartWithIE = "false"
/>
</Settings>
</Build>
<OtherProjectSettings
CopyProjectDestinationFolder = ""
CopyProjectUncPath = ""
CopyProjectOption = "0"
ProjectView = "ProjectFiles"
ProjectTrust = "0"
/>
</CSHARP>
</VisualStudioProject>
--- NEW FILE: src.csproj ---
<VisualStudioProject>
<CSHARP
ProjectType = "Local"
ProductVersion = "7.0.9466"
SchemaVersion = "1.0"
ProjectGuid = "{4859B9E5-3F65-4517-878C-AFC58B9D0035}"
>
<Build>
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
AssemblyName = "NMock"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
DefaultTargetSchema = "IE50"
DelaySign = "false"
OutputType = "Library"
RootNamespace = "NMock"
StartupObject = ""
>
<Config
Name = "Debug"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "DEBUG;TRACE"
DocumentationFile = ""
DebugSymbols = "true"
FileAlignment = "4096"
IncrementalBuild = "true"
Optimize = "false"
OutputPath = "bin\Debug\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
<Config
Name = "Release"
AllowUnsafeBlocks = "false"
BaseAddress = "285212672"
CheckForOverflowUnderflow = "false"
ConfigurationOverrideFile = ""
DefineConstants = "TRACE"
DocumentationFile = ""
DebugSymbols = "false"
FileAlignment = "4096"
IncrementalBuild = "false"
Optimize = "true"
OutputPath = "bin\Release\"
RegisterForComInterop = "false"
RemoveIntegerChecks = "false"
TreatWarningsAsErrors = "false"
WarningLevel = "4"
/>
</Settings>
<References>
<Reference
Name = "System"
AssemblyName = "System"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.dll"
/>
<Reference
Name = "System.Data"
AssemblyName = "System.Data"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.Data.dll"
/>
<Reference
Name = "System.XML"
AssemblyName = "System.XML"
HintPath = "C:\WINNT\Microsoft.NET\Framework\v1.0.3705\System.XML.dll"
/>
</References>
</Build>
<Files>
<Include>
<File
RelPath = "AssemblyInfo.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\DynamicMock.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\IMock.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\IVerifiable.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\Method.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\Mock.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\MockCall.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\VerifyException.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\Constraints\Constraints.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\Constraints\IConstraint.cs"
SubType = "Code"
BuildAction = "Compile"
/>
<File
RelPath = "NMock\Dynamic\ClassGenerator.cs"
SubType = "Code"
BuildAction = "Compile"
/>
</Include>
</Files>
</CSHARP>
</VisualStudioProject>
--- NEW FILE: AssemblyInfo.cs ---
using System.Reflection;
using System.Runtime.CompilerServices;
//
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
//
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below:
[assembly: AssemblyVersion("1.0.*")]
//
// In order to sign your assembly you must specify a key to use. Refer to the
// Microsoft .NET Framework documentation for more information on assembly signing.
//
// Use the attributes below to control which key is used for signing.
//
// Notes:
// (*) If no key is specified, the assembly is not signed.
// (*) KeyName refers to a key that has been installed in the Crypto Service
// Provider (CSP) on your machine. KeyFile refers to a file which contains
// a key.
// (*) If the KeyFile and the KeyName values are both specified, the
// following processing occurs:
// (1) If the KeyName can be found in the CSP, that key is used.
// (2) If the KeyName does not exist and the KeyFile does exist, the key
// in the KeyFile is installed into the CSP and used.
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility.
// When specifying the KeyFile, the location of the KeyFile should be
// relative to the project output directory which is
// %Project Directory%\obj\<configuration>. For example, if your KeyFile is
// located in the project directory, you would specify the AssemblyKeyFile
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")]
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework
// documentation for more information on this.
//
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile("")]
[assembly: AssemblyKeyName("")]
|
|
From: <sm...@us...> - 2002-12-16 14:50:17
|
Update of /cvsroot/nmock/nmock/src/NMock
In directory sc8-pr-cvs1:/tmp/cvs-serv14529/src/NMock
Modified Files:
Mock.cs
Added Files:
MockCall.cs Method.cs
Log Message:
Refactoring.
Pulled out Method object
--- NEW FILE: MockCall.cs ---
using System;
using NMock.Constraints;
namespace NMock
{
public class MockCall
{
private IConstraint[] expectedArgs;
private object returnValue;
private Exception e;
public MockCall(object returnValue, Exception e, object[] expectedArgs)
{
this.expectedArgs = argsAsConstraints(expectedArgs);
this.returnValue = returnValue;
this.e = e;
}
public virtual bool HasExpectations
{
get { return expectedArgs.Length > 0; }
}
private IConstraint[] argsAsConstraints(object[] args)
{
if (null == args)
{
return new IConstraint[0];
}
IConstraint[] result = new IConstraint[args.Length];
for (int i = 0; i < result.Length; ++i)
{
result[i] = argAsConstraint(args[i]);
}
return result;
}
private IConstraint argAsConstraint(object arg)
{
IConstraint constraint = arg as IConstraint;
if (constraint != null)
{
return constraint;
}
return arg == null ? (IConstraint)new IsAnything() : (IConstraint)new IsEqual(arg);
}
public virtual object Call(string methodName, object[] actualArgs)
{
checkArguments(methodName, actualArgs);
if (e != null)
{
throw e;
}
return returnValue;
}
private void checkArguments(string methodName, object[] actualArgs)
{
if ( HasExpectations )
{
Mock.Assertion.AssertEquals("x() called with incorrect number of parameters",
expectedArgs.Length, actualArgs.Length);
for (int i = 0; i < expectedArgs.Length; i++)
{
checkConstraint(methodName, expectedArgs[i], actualArgs[i], i);
}
}
}
private void checkConstraint(string methodName, IConstraint expected, object actual, int index)
{
if (!expected.Eval(actual))
{
String messageFormat = "{0}() called with incorrect parameter ({1})";
String message = String.Format(messageFormat, methodName, index + 1);
throw new VerifyException(message, expected.Message, actual);
}
}
}
public class MockNoCall : MockCall
{
public MockNoCall() : base(null, null, null)
{
}
public override object Call(string methodName, object[] actualArgs)
{
throw new VerifyException(methodName + "() called", 0, 1);
}
}
}
--- NEW FILE: Method.cs ---
using System;
using System.Collections;
namespace NMock
{
/// <summary>
/// nb. Shouldn't return value belong to the Call?
/// </summary>
public class Method : IVerifiable
{
private static object NO_RETURN_VALUE = new object();
private string name;
private object returnValue = NO_RETURN_VALUE;
private int timesCalled = 0;
private CallSequence expectations;
public Method(string aName)
{
name = aName;
expectations = new CallSequence(aName);
}
public virtual object ReturnValue
{
set { returnValue = value; }
get { return returnValue; }
}
public virtual bool HasReturnValue
{
get { return ! Object.ReferenceEquals(NO_RETURN_VALUE, returnValue); }
}
public virtual bool HasNoExpectations
{
get { return expectations.Count == 0; }
}
public virtual string Name
{
get { return name; }
}
public virtual void AddExpected(MockCall aCall)
{
expectations.Add(aCall);
}
public virtual object Call(params object[] parameters)
{
MockCall mockCall = expectations[timesCalled];
timesCalled++;
return mockCall.Call(name, parameters);
}
public virtual void Verify()
{
Mock.Assertion.AssertEquals(name + "() " + CallCountErrorMessage(),
expectations.Count, timesCalled);
}
private string CallCountErrorMessage()
{
return (timesCalled == 0 ? "never called" : "not called enough times");
}
/// <summary>
/// Specialised collection class for Method Calls
/// </summary>
public class CallSequence
{
private string name;
private ArrayList sequence = new ArrayList();
public CallSequence(string aName)
{
name = aName;
}
public MockCall this[int timesCalled]
{
get
{
if (sequence.Count == timesCalled)
{
throw new VerifyException(name + "() called too many times", sequence.Count, timesCalled + 1);
}
return (MockCall)sequence[timesCalled];
}
}
public int Count
{
get { return sequence.Count; }
}
public void Add(MockCall aCall)
{
sequence.Add(aCall);
}
}
}
}
Index: Mock.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Mock.cs,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** Mock.cs 12 Dec 2002 21:39:43 -0000 1.5
--- Mock.cs 16 Dec 2002 14:49:46 -0000 1.6
***************
*** 5,25 ****
namespace NMock
{
-
public class Mock : IMock
{
-
private string name;
! private object obj;
private bool strict;
! private IDictionary expectations;
! private IDictionary values;
! private IDictionary counters;
public Mock(string name)
{
this.name = name;
! expectations = new Hashtable();
! values = new Hashtable();
! counters = new Hashtable();
}
--- 5,19 ----
namespace NMock
{
public class Mock : IMock
{
private string name;
! private object instance;
private bool strict;
! private IDictionary methods;
public Mock(string name)
{
this.name = name;
! methods = new Hashtable();
}
***************
*** 32,37 ****
public virtual object MockInstance
{
! get { return obj; }
! set { obj = value; }
}
--- 26,31 ----
public virtual object MockInstance
{
! get { return instance; }
! set { instance = value; }
}
***************
*** 42,56 ****
}
- public virtual void Verify()
- {
- foreach (String methodName in expectations.Keys)
- {
- IList list = (IList) expectations[methodName];
- int count = counter(methodName);
- string msg = count == 0 ? "never called" : "not called enough times";
- Assertion.AssertEquals(methodName + "() " + msg, list.Count, count);
- }
- }
-
public virtual void Expect(string methodName, params object[] args)
{
--- 36,39 ----
***************
*** 60,210 ****
public virtual void ExpectNoCall(string methodName)
{
! addExpectation(new MockNoCall(methodName));
}
public virtual void ExpectAndReturn(string methodName, object result, params object[] args)
{
! addExpectation(new MockCall(methodName, result, null, args));
}
public virtual void ExpectAndThrow(string methodName, Exception e, params object[] args)
{
! addExpectation(new MockCall(methodName, null, e, args));
}
public virtual void SetupResult(string methodName, object returnVal)
{
! values[methodName] = returnVal;
}
public virtual object Call(string methodName, params object[] args)
{
! if (values.Contains(methodName))
{
! return values[methodName];
}
! IList methodExpectations = (IList) expectations[methodName];
! if (methodExpectations == null)
! {
if ( strict )
{
! throw new VerifyException(methodName + "() called too many times", 0, counter(methodName) + 1);
}
return null;
}
! if (methodExpectations.Count == counter(methodName))
! {
! throw new VerifyException(methodName + "() called too many times", methodExpectations.Count, counter(methodName) + 1);
! }
! MockCall mockCall = (MockCall)methodExpectations[counter(methodName)];
! if (mockCall is MockNoCall)
! {
! throw new VerifyException(methodName + "() called", 0, 1);
! }
! increment(methodName);
! return mockCall.Call(methodName, args);
}
! private void increment(string methodName)
! {
! counters[methodName] = counter(methodName) + 1;
! }
!
! private int counter(string methodName)
! {
! return counters.Contains(methodName) ? (int)counters[methodName] : 0;
! }
!
! private void addExpectation(MockCall call)
{
! IList list = (IList) expectations[call.MethodName];
! if (list == null)
{
! list = new ArrayList();
! expectations[call.MethodName] = list;
}
- list.Add(call);
}
! private class MockCall
{
! public string MethodName;
! private IConstraint[] expectedArgs;
! private object returnValue;
! private Exception e;
!
! public MockCall(string methodName, object returnValue, Exception e, object[] expectedArgs)
! {
! this.MethodName = methodName;
! this.returnValue = returnValue;
! this.e = e;
! this.expectedArgs = argsAsConstraints(expectedArgs);
! }
!
! private IConstraint[] argsAsConstraints(object[] args)
! {
! if (args == null)
! {
! return new IConstraint[0];
! }
! IConstraint[] result = new IConstraint[args.Length];
! for (int i = 0; i < args.Length; ++i)
! {
! result[i] = argAsConstraint(args[i]);
! }
! return result;
! }
!
! private IConstraint argAsConstraint(object arg)
! {
! IConstraint constraint = arg as IConstraint;
! if (constraint != null)
! {
! return constraint;
! }
! return arg == null ? (IConstraint)new IsAnything() : (IConstraint)new IsEqual(arg);
! }
!
! public virtual object Call(string methodName, object[] actualArgs)
! {
! if ( this.expectedArgs.Length > 0 )
! {
! // assert that the correct number of arguments were passed
! Assertion.AssertEquals("x() called with incorrect number of parameters", this.expectedArgs.Length, actualArgs.Length);
!
! // assert that each passed in arg is validated by the appropriate predicate.
! for (int i = 0; i < this.expectedArgs.Length; i++)
! {
! IConstraint expectedArg = expectedArgs[i];
! object actualArg = actualArgs[i];
!
! if (!expectedArg.Eval(actualArg))
! {
! String messageFormat = "{0}() called with incorrect parameter ({1})";
! String message = String.Format(messageFormat, methodName, i + 1);
! throw new VerifyException(message, expectedArg.Message, actualArg);
! }
! }
! }
!
! // if exception setup to be thrown, throw it
! if (e != null)
! {
! throw e;
! }
! // otherwise return desired value
! return returnValue;
! }
}
!
! private class MockNoCall : MockCall
{
! public MockNoCall(string methodName) : base(methodName, null, null, null)
! {
}
}
! private class Assertion
{
public static void Assert(string message, bool expression)
--- 43,108 ----
public virtual void ExpectNoCall(string methodName)
{
! addExpectation(methodName, new MockNoCall());
}
public virtual void ExpectAndReturn(string methodName, object result, params object[] args)
{
! addExpectation(methodName, new MockCall(result, null, args));
}
public virtual void ExpectAndThrow(string methodName, Exception e, params object[] args)
{
! addExpectation(methodName, new MockCall(null, e, args));
}
public virtual void SetupResult(string methodName, object returnVal)
{
! getMethod(methodName).ReturnValue = returnVal;
}
public virtual object Call(string methodName, params object[] args)
{
! Method method = getMethod(methodName);
! if (method.HasReturnValue)
{
! return method.ReturnValue;
}
! if (method.HasNoExpectations) {
if ( strict )
{
! throw new VerifyException(method.Name + "() called too many times", 0, 1);
}
return null;
}
! return method.Call(args);
}
! public virtual void Verify()
{
! foreach (Method method in methods.Values)
{
! method.Verify();
}
}
! private void addExpectation(string methodName, MockCall call)
{
! getMethod(methodName).AddExpected(call);
}
!
! private Method getMethod(string methodName)
{
! Method found = (Method)methods[methodName];
! if (found == null)
! {
! found = new Method(methodName);
! methods[methodName] = found;
}
+ return found;
}
!
! public class Assertion
{
public static void Assert(string message, bool expression)
***************
*** 223,232 ****
}
}
-
}
-
-
-
}
-
}
--- 121,125 ----
|
|
From: <sm...@us...> - 2002-12-16 14:49:01
|
Update of /cvsroot/nmock/nmock/src/NMock/Dynamic
In directory sc8-pr-cvs1:/tmp/cvs-serv14056/src/NMock/Dynamic
Modified Files:
ClassGenerator.cs
Log Message:
Made getBoxingOpCode public to allow tests access.
This is probably the wrong solution.
Index: ClassGenerator.cs
===================================================================
RCS file: /cvsroot/nmock/nmock/src/NMock/Dynamic/ClassGenerator.cs,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** ClassGenerator.cs 12 Dec 2002 21:39:43 -0000 1.3
--- ClassGenerator.cs 16 Dec 2002 14:48:49 -0000 1.4
***************
*** 132,136 ****
}
! internal OpCode getBoxingOpCode( Type aType )
{
if (boxingOpCodes == null)
--- 132,136 ----
}
! public OpCode getBoxingOpCode( Type aType )
{
if (boxingOpCodes == null)
|
|
From: <exo...@us...> - 2002-12-14 21:34:03
|
Update of /cvsroot/nmock/nmock/tools In directory sc8-pr-cvs1:/tmp/cvs-serv16177/tools Added Files: nant.exe Log Message: tortise skipped this for some reason --- NEW FILE: nant.exe --- (This appears to be a binary file; contents omitted.) |
Update of /cvsroot/nmock/nmock/tools In directory sc8-pr-cvs1:/tmp/cvs-serv14230/tools Added Files: NAnt.Core.dll NAnt.DotNetTasks.dll NAnt.NUnit1Tasks.dll NAnt.NUnitTasks.dll NDoc.Core.dll NUnitCore.dll nunit.framework.dll Log Message: set everything up to make nmock run under ccnet. included distribution of NAnt used by ccnet in tools folder. developers should run build.bat to perform the NAnt build. test target now uses nunit2 target. --- NEW FILE: NAnt.Core.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: NAnt.DotNetTasks.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: NAnt.NUnit1Tasks.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: NAnt.NUnitTasks.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: NDoc.Core.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: NUnitCore.dll --- (This appears to be a binary file; contents omitted.) --- NEW FILE: nunit.framework.dll --- (This appears to be a binary file; contents omitted.) |
|
From: <exo...@us...> - 2002-12-14 21:28:12
|
Update of /cvsroot/nmock/nmock/ccnet In directory sc8-pr-cvs1:/tmp/cvs-serv14230/ccnet Added Files: ccnet-nmock.bat ccnet.config Log Message: set everything up to make nmock run under ccnet. included distribution of NAnt used by ccnet in tools folder. developers should run build.bat to perform the NAnt build. test target now uses nunit2 target. --- NEW FILE: ccnet-nmock.bat --- title CCNET "C:\Program Files\CruiseControl.NET\bin\ccnet.exe" --- NEW FILE: ccnet.config --- <cruisecontrol> <project name="nmock"> <projectUrl>http://teetor/nmock</projectUrl> <sourceControl name="cvs"> <executable>cvs.exe</executable> <workingDirectory>..</workingDirectory> </sourceControl> <build> <executable>C:\Program Files\CruiseControl.NET\tools\nant\NAnt.exe</executable> <baseDirectory>..</baseDirectory> <buildFile>nmock.build</buildFile> <targetList> <target>cruise</target> </targetList> <buildTimeout>30000</buildTimeout> </build> <publishers> <email from="cc...@th..." mailhost="mother.thoughtworks.com"> <users> <user name="buildmaster" group="buildmaster" address="jo...@tr..."/> <user name="joewalnes" group="developers" address="jo...@tr..."/> <user name="exortech" group="developers" address="nm...@ex..."/> </users> <groups> <group name="developers" notification="change"/> <group name="buildmaster" notification="always"/> </groups> </email> <xmllogger> <logDir>log</logDir> </xmllogger> </publishers> <logDir>log</logDir> <sleep>60000</sleep> </project> </cruisecontrol> |