by Patrik Hägne via Legend and truth on 2/25/2010 7:36:00 PM
I added a nifty little feature in FakeItEasy today, not 100% sure about the naming though so if you have any ideas pleas tell me. The idea is that when you configure a call you can specify several values and each time a call is made to the configured member (property or method) the next value from the collection will be returned. Here’s what it looks like in action:
public interface ICurrentTimeProvider { DateTime CurrentTime { get; } } [Test] public void Example() { var timeProvider = A.Fake<ICurrentTimeProvider>(); A.CallTo(() => timeProvider.CurrentTime).ReturnsNextFromSequence( DateTime.Parse("2000-01-01 01:00"), DateTime.Parse("2000-01-01 01:01"), DateTime.Parse("2000-01-01 01:02")); Console.WriteLine(timeProvider.CurrentTime); // Writes 2000-01-01 01:00 Console.WriteLine(timeProvider.CurrentTime); // Writes 2000-01-01 01:01 Console.WriteLine(timeProvider.CurrentTime); // Writes 2000-01-01 01:02 }
Original Post: Return from sequence in FakeItEasy
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.