Verify that method wasn't called

12 views
Skip to first unread message

lexer

unread,
Nov 24, 2008, 9:49:42 AM11/24/08
to Moq Discussions
In Rhino Mocks it is possible to verify that method wasn't called. Can
we do it with Moq?

Brian J. Cardiff

unread,
Nov 24, 2008, 9:56:30 AM11/24/08
to moq...@googlegroups.com
you can add an "expectation".

var mock = new Mock<IWithFoo>();
mock.Expect(x => x.Foo(It.IsAny<string>())).Never();

where
public interface IWithFoo {
    void Foo(string s);
}

but I would like a way to stand for that at the end of the tests near the Verify method call.

Brian J. Cardiff
bcardiff(?)gmail.com
.

lexer

unread,
Nov 24, 2008, 11:07:24 AM11/24/08
to Moq Discussions
Thanks Brian.

On 24 нояб, 19:56, "Brian J. Cardiff" <bcard...@gmail.com> wrote:
> you can add an "expectation".
>
> var mock = new Mock<IWithFoo>();
> mock.Expect(x => x.Foo(It.IsAny<string>())).Never();
>
> where
> public interface IWithFoo {
>     void Foo(string s);
>
> }
>
> but I would like a way to stand for that at the end of the tests near the
> Verify method call.
>
> Brian J. Cardiff
> bcardiff(?)gmail.com
> .
>

Sam

unread,
Jan 20, 2009, 10:12:22 AM1/20/09
to Moq Discussions
Brian,
Can I add my vote for a way of Verifying that a method was not
called at the end of the test?

Thanks,

Sam

On Nov 24 2008, 2:56 pm, "Brian J. Cardiff" <bcard...@gmail.com>
wrote:
> you can add an "expectation".
>
> var mock = new Mock<IWithFoo>();
> mock.Expect(x => x.Foo(It.IsAny<string>())).Never();
>
> where
> public interface IWithFoo {
>     void Foo(string s);
>
> }
>
> but I would like a way to stand for that at the end of the tests near the
> Verify method call.
>
> Brian J. Cardiff
> bcardiff(?)gmail.com
> .
>
Reply all
Reply to author
Forward
0 new messages