by Patrik Hägne via Legend and truth on 12/19/2009 12:40:00 PM
I’ve just updated the way to configure any call to faked objects in FakeItEasy, the syntax is new and also you can now configure return values.
Let’s say you have an interface providing localized text resources like this:
public interface ILocalizedResources { string SomeText { get; } string SomeOtherText { get; } }
When you fake this interface any of the properties would return null when not configured but you might have several tests that are dependant on that the values are non null strings but still you don’t want to have to configure each individual property in the set up of you fixture. Now you can do exactly that:
var resources = A.Fake<ILocalizedResources>(); Any.CallTo(resources).WithReturnType<string>().Returns("");
Of course you can still configure any call to do anything you want just as before, for example:
var resources = A.Fake<ILocalizedResources>(); Any.CallTo(resources).Throws(new Exception());
Original Post: Configuring any call to an object
The content of the postings is owned by the respective author. CSharpFeeds is not responsible for the contents of the postings. This site is automatically generated and cannot be reviewed for abusive content. If you find abusive content on CSharpFeeds, please contact us. Designated trademarks and brands are the property of their respective owners. All rights reserved.