|
From: Mike C. <mc...@us...> - 2007-08-16 15:14:50
|
Update of /cvsroot/nmock/nmock2/src/NMock2/Internal In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv27332/src/NMock2/Internal Modified Files: ExpectationBuilder.cs Log Message: Support mixing Matchers and non-Matchers in expected argument lists. Index: ExpectationBuilder.cs =================================================================== RCS file: /cvsroot/nmock/nmock2/src/NMock2/Internal/ExpectationBuilder.cs,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ExpectationBuilder.cs 1 Feb 2006 18:54:44 -0000 1.2 --- ExpectationBuilder.cs 16 Aug 2007 15:14:50 -0000 1.3 *************** *** 130,146 **** } ! public IMatchSyntax this[params Matcher[] matchers] { get { ! expectation.ArgumentsMatcher = new IndexGetterArgumentsMatcher(matchers); return builder; } } - - public IMatchSyntax this[params object[] equalValues] - { - get { return this[IsEqualMatchersFor(equalValues)]; } - } } --- 130,141 ---- } ! public IMatchSyntax this[params object[] expectedArguments] { get { ! expectation.ArgumentsMatcher = new IndexGetterArgumentsMatcher(ArgumentMatchers(expectedArguments)); return builder; } } } *************** *** 173,180 **** } ! public IValueSyntax this[params Matcher[] indexMatchers] { get { matchers = new Matcher[indexMatchers.Length + 1]; Array.Copy(indexMatchers, matchers, indexMatchers.Length); --- 168,176 ---- } ! public IValueSyntax this[params object[] expectedArguments] { get { + Matcher[] indexMatchers = ArgumentMatchers(expectedArguments); matchers = new Matcher[indexMatchers.Length + 1]; Array.Copy(indexMatchers, matchers, indexMatchers.Length); *************** *** 184,192 **** } - public IValueSyntax this[params object[] equalValues] - { - get { return this[IsEqualMatchersFor(equalValues)]; } - } - public IMatchSyntax To(Matcher matcher) { --- 180,183 ---- *************** *** 243,263 **** } ! public IMatchSyntax With(params Matcher[] argumentMatchers) { ! expectation.ArgumentsMatcher = new ArgumentsMatcher(argumentMatchers); return this; - } - - public IMatchSyntax With(params object[] equalArgumentValues) - { - return With(IsEqualMatchersFor(equalArgumentValues)); } ! private static Matcher[] IsEqualMatchersFor(object[] equalArgumentValues) { ! Matcher[] matchers = new Matcher[equalArgumentValues.Length]; for (int i = 0; i < matchers.Length; i++) { ! matchers[i] = new EqualMatcher(equalArgumentValues[i]); } return matchers; --- 234,250 ---- } ! public IMatchSyntax With(params object[] expectedArguments) { ! expectation.ArgumentsMatcher = new ArgumentsMatcher(ArgumentMatchers(expectedArguments)); return this; } ! private static Matcher[] ArgumentMatchers(object[] expectedArguments) { ! Matcher[] matchers = new Matcher[expectedArguments.Length]; for (int i = 0; i < matchers.Length; i++) { ! object o = expectedArguments[i]; ! matchers[i] = (o is Matcher) ? (Matcher) o : new EqualMatcher(o); } return matchers; |