Configuring a call on a strict fake without Returns
See original GitHub issueHi, due to issue #899 I upgraded FakeItEasy from version 2.1.0 to 2.3.2 and mentioned a different behavior. In 2.1.0 if a call to a strict fake is configured without a return then the calls to the fake work and the default value is returned. In 2.3.2 there is only an exception with the message “Call to non configured method “Bar” of strict fake”.
In my opinion the new behavior is ok but a better message would be nice, something like: “Call to configured method “Bar” of strict fake has no return specification”
public interface IFoo
{
bool Bar(string x);
}
[TestMethod]
public void TestMethod1()
{
var fake = A.Fake<IFoo>(x => x.Strict());
A.CallTo(() => fake.Bar(A<string>.Ignored)); // In 2.1.0 the default value was returned
Assert.IsFalse(fake.Bar("Foobar")); // In 2.3.2 an exception is thrown
}
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Why am I getting 'Call to unconfigured method' when using ...
So in your configuration, Wrapping is added making the Fake attempt to forward all calls to the wrapped object. Then Strict , so...
Read more >Specifying a Call to Configure
One of the first steps in configuring a fake object's behavior is to specify which call to configure. Like most FakeItEasy actions, this...
Read more >Specifying a Fake's Behavior - FakeItEasy Succinctly Ebook
Learn about return values, doing nothing, strict and exceptions in the chapter "Specifying a Fake's Behavior" of Syncfusion FakeItEasy free ...
Read more >Add example of how to use A.CallTo() with anonymous types.
Call to unconfigured method of strict fake: IPowershellObjectConverter.ToParameters`1[<>f__AnonymousType1`3[System.String,System.Int32,System.
Read more >Complying with the Telemarketing Sales Rule
Calls are not considered “unsolicited” when placed by consumers in response to a prerecorded call. If a seller or telemarketer “upsells” a consumer...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for alerting us, @thunderbird55. The code you have is an error, in that
A.CallTo
without a directive regarding the method’s behaviour is meaningless.A.CallTo
was always intended to have no effect without such a directive (e.g.Returns
,DoesNothing
, etc.), and this was remedied when we fixed #556. We do regret that fixing this bug causes some inconvenience for people who’ve been relying on the behaviour. The solution is to specify an action. In this case, I guess you’d want.Returns(false)
.If you’re using a modern Visual Studio, consider picking up the FakeItEasy Analyzer, which will warn you of this incorrect usage and give you a chance to correct it before your tests even fail.
Ok, then I would say let’s close this issue. I thought maybe there is only an additional if necessary.
I totally agree with you. In my former company we had a similar approach. In my current company the philosophy is “don’t change anything”. But better we don’t talk about this because I’m getting angry when I’m thinking about this 😦