instead of CreateMock use DynamicMock...

it's the difference between strict and non mocks...favor non-strict (dynamic
mocks)

On Thu, Oct 22, 2009 at 9:10 AM, hitechnical <[email protected]> wrote:

>
> Ok, I am starting on it now .. to try myself i wrote this code. What I
> am trying to do here is, I've mocked User object on which i expect a
> call from UserValidationService.IsValidUser method. Below is the code,
>
>    public class UserValidationService : IUserValidationService
>    {
>        public bool IsValidUser(IUser user)
>        {
>            if (String.IsNullOrEmpty(user.UserName) ||
> String.IsNullOrEmpty(user.Password))
>                return false;
>            return true;
>        }
>    }
>
> // The test code.
>
>            MockRepository mock = new MockRepository();
>
>            var validationService
>                = new UserValidationService();
>            var userToTest
>                = mock.CreateMock<IUser>(null);
>
>            Expect.On(userToTest).Call(userToTest.Name).Return
> ("Name");
>            Expect.On(userToTest).Call(userToTest.Password).Return
> ("Password");
>
>            mock.ReplayAll();
>            validationService.IsValidUser(userToTest);
>            mock.VerifyAll();
>
> I get this error whenever VerifyAll is executed:
>        Rhino.Mocks.Exceptions.ExpectationViolationException:
> IUser.get_UserName(); Expected #0, Actual #1.
>
> Can someone enlight me?
>
> >
>


-- 
Tim Barcz
Microsoft C# MVP
Microsoft ASPInsider
http://timbarcz.devlicio.us
http://www.twitter.com/timbarcz

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Rhino.Mocks" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rhinomocks?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to