Hegg
2010-02-17 21:02:48 UTC
Greetings,
I have been building some tests and thought I'd try out the new
"AssertWasNotCalled" extension method. It seems to work as I'd expect
on methods with no parameters, but when I have a method with a
parameter, I can't seem to find a way to have it ignore those
parameters - that is, I want to assert that a specific method was
never called with any parameter ever.
For example, I'm using a interface which has a .List() method and
a .Delete(string name) method. Using the AAA style syntax, my test
uses AssertWasCalled(x => x.List()) and then attempts to
AssertWasNotCalled(x => x.Delete("test")). Since my code was awesome,
it succeeded, but I also like to "break" my methods sometimes just to
be sure I wrote a test correctly. I added a call to
the .Delete("test") in the method and the test now fails as expected.
However, if I change to .Delete("any other text"), the test passes
because "any other text" does not equal "test". Essentially I want to
ensure that the .Delete() method was never called, regardless of
parameters.
Is there a way to IgnoreArguments() on the AssertWasNotCalled()
somehow, or would I be looking at making a strict mock (and
consequently setting up expectations on every method call)?
Just more of a "how do I" question than anything. :)
I have been building some tests and thought I'd try out the new
"AssertWasNotCalled" extension method. It seems to work as I'd expect
on methods with no parameters, but when I have a method with a
parameter, I can't seem to find a way to have it ignore those
parameters - that is, I want to assert that a specific method was
never called with any parameter ever.
For example, I'm using a interface which has a .List() method and
a .Delete(string name) method. Using the AAA style syntax, my test
uses AssertWasCalled(x => x.List()) and then attempts to
AssertWasNotCalled(x => x.Delete("test")). Since my code was awesome,
it succeeded, but I also like to "break" my methods sometimes just to
be sure I wrote a test correctly. I added a call to
the .Delete("test") in the method and the test now fails as expected.
However, if I change to .Delete("any other text"), the test passes
because "any other text" does not equal "test". Essentially I want to
ensure that the .Delete() method was never called, regardless of
parameters.
Is there a way to IgnoreArguments() on the AssertWasNotCalled()
somehow, or would I be looking at making a strict mock (and
consequently setting up expectations on every method call)?
Just more of a "how do I" question than anything. :)
--
You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to rhinomocks+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.
You received this message because you are subscribed to the Google Groups "Rhino.Mocks" group.
To post to this group, send email to ***@googlegroups.com.
To unsubscribe from this group, send email to rhinomocks+***@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rhinomocks?hl=en.