Does anyone know the equivalent of Moq It.IsAny<T>
in FakeItEasy ?
I want to do assert that a method was called with an instance of a Type
v.Do(new Foo());
I tried:
A.CallTo(() => v.Do(A<Foo>.Ignored)).MustHaveHappened();
but this also accepts v.Do()
;
You're right in the A<Foo>.Ignored
(or A<Foo>._
) is the equivalent of It.IsAny<Foo>
in Moq.
It seems that you've hit a bug if what you say is actually correct. I'll get on it as soon as possible.
EDIT I created the following integration test to reproduced the bug but the test passes so I'm not able to reproduce it, could you provide a code sample?
[Test]
public void Should_fail_assertion_when_overload_with_no_parameters_has_been_called_but_the_assertion_is_for_overload_with_parameters_but_ignoring_them()
{
// Arrange
var fake = A.Fake<ITypeWithOverloadedMethods>();
// Act
fake.Foo();
// Assert
Assert.Throws<ExpectationException>(() => A.CallTo(() => fake.Foo(A<int>._)).MustHaveHappened());
}
public interface ITypeWithOverloadedMethods
{
void Foo();
void Foo(int argument);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With