I'm totally new to Moq, I'm used to Rhino Mock.
I was reading the wiki page on Google Code, imaging this test setup:
var respository = factory.Create<IMyRepository>();
respository.Setup( r => r.MyMethod ( It.IsAny<Int32>() ) ).Verifiable();
... 
respository.Verify( r => r. MyMethod( It.IsAny<Int32>() ), Times.Once() );
Don't you think could be interesting to be able to set the expected number of times at setup times and not only at verify time? In this sample there is duplicate code (the expression) required only to set the expected times.
.m
_____________
Mauro Servienti 
could you expand on this with a sample?
Cheers,
.m
_____________
Mauro Servienti  
--
Post: moq...@googlegroups.com
Unsubscribe: moqdisc-u...@googlegroups.com
// Arrange
var respository = new Mock<IMyRepository>();
// Act
// Do something that uses the (mock) repository
// Assert
// Arrange
var respository = new Mock<IMyRepository>();
repository.Setup( r => r. MyMethod( It.IsAny<Int32>() ).Returns( ... );
// Act
// Do something that uses the (mock) repository
// Assert
respository.Verify( r => r. MyMethod( It.IsAny<Int32>() ), Times.Once() );
.m
_____________
Mauro Servienti 
-----Original Message-----
From: moq...@googlegroups.com [mailto:moq...@googlegroups.com] On Behalf Of Andy McMullan
Sent: martedì 31 maggio 2011 11:39
To: moq...@googlegroups.com
Subject: Re: [Moq] setting expected "Times" during setup
-- 
Post: moq...@googlegroups.com
Unsubscribe: moqdisc-u...@googlegroups.com
Yes, though in my experience most of the time you don't need to verify
that the call on the mock was made when the mocked method returns a
value, because the assert portion of the test will check that the
returned value was used, and therefore implicitly verify that the
mocked method was called.
Only a small percentage of my tests (< 10% I'd guess) use Verify, and
very few of those Verify calls have a corresponding Setup call.
Ditto here
/kzu from Android
Cheers,
.m
_____________
Mauro Servienti  
-----Original Message-----
From: moq...@googlegroups.com [mailto:moq...@googlegroups.com] On Behalf Of Andy McMullan
Sent: martedì 31 maggio 2011 12:44
To: moq...@googlegroups.com
Subject: Re: [Moq] setting expected "Times" during setup
--
Post: moq...@googlegroups.com
Unsubscribe: moqdisc-u...@googlegroups.com