Daniel,
That sounds good to me. When can I start using it ;-)
Sam
On Nov 13, 2:50 pm, "Brian J. Cardiff" <
bcard...@gmail.com> wrote:
> I was having in mind scenarios where I would want to constraint allowed
> values, for example, ensure that the warning message explains something of
> the invalid status of the model.
>
> Then, if some arguments can be restricted, an overload shouldn't be just a
> method with same name, but a method that can be extended with "optional"
> parameters. In this thought I express an "parameter-name-based". Because an
> overload could be Bar(int, int) and Bar(string, string), If an expectation
> is set on the former, how a call to the later would be treated?
>
> Although Kzu and I have talked and agree that the most common scenario would
> to not restrict arguments in overloads.
>
> Brian J. Cardiff
> bcardiff(?)
gmail.com
> .
>
> On Thu, Nov 13, 2008 at 9:59 AM, Daniel Cazzulino <
dan...@cazzulino.com>wrote:
>
>
>
> > Overload resolution in .net is based on argument position and type, so if
> > you specify those in the Expect, I don't see why they will be tricky
>
> > Sent from my iPod
>
> > On Nov 12, 2008, at 6:39 PM, "Brian J. Cardiff" <
bcard...@gmail.com>
> > wrote:
>
> > I like it.
>
> > Overloads will be tricky.
> > Some overload appends arguments, others prepend.
> > Overload detection should be argument-name-based match, because type-based
> > match won't work, think of String.format.
>
> > Brian J. Cardiff
> > bcardiff(?)
gmail.com
> > .
>
> > On Wed, Nov 12, 2008 at 6:16 PM, Daniel Cazzulino < <
dan...@cazzulino.com>
> >
dan...@cazzulino.com> wrote:
>
> >> Ahh... this just gave me a cool idea!
> >> The following compiles just fine (not with current moq, but plain C#):
>
> >> mock.Expect<int, string, bool>(m => m.Do);
>
> >> So you could do away with the It.IsAny<T> that way !!! :D:D:D
>
> >> Adding an AnyOverload() might be interesting.
> >> What do others think?
>
> >> On Wed, Nov 12, 2008 at 3:18 PM, Sam < <
samuel.j...@gmail.com>
> >>
samuel.j...@gmail.com> wrote:
>
> >>> How's this for an idea for creating more robust tests?
>
> >>> I've just had a case where I'm mocking the ILog interface in Log4Net.
> >>> Basically I want to ensure that my class logs a Warning in a
> >>> particular case. Problem is, ILog has multiple overloads of the the
> >>> WarnFormat, and I have to set the exectation on the one that my class
> >>> is using; if, for example, my message needs another parameter, I'll
> >>> need to remember to change the expectation to point to a different
> >>> overload of WarnFormat. Not very robust!
>
> >>> Would it be possible to allow verifiable Expectations to be set for
> >>> any overload of a method? Obviously you couldn't set expectations for
> >>> individual parameters: it would just allow you to assert that a method
> >>> call had been made.
>
> >>> Suggested syntax:
>
> >>> Mock<ILog> mockLog = new Mock<ILog>();
> >>> mockLog.Expect(m => m.WarnFormat(It.IsAny<string>(), It.IsAny<object>
> >>> ())).AnyOverload().Verifiable();- Hide quoted text -
>
> - Show quoted text -