Once more Fluent Assertions has come in handy for providing a simple way of asserting the execution time of an Action (in this case a big bit of data formatting), buried away almost as foot note on their docs page is:
New in version 1.4 is a method to assert that the execution time of particular method or action does not exceed a predefined value. To verify the execution time of a method, use the following syntax:
var subject = new SomePotentiallyVerySlowClass();
subject.ExecutionTimeOf(s => s.ExpensiveMethod()).ShouldNotExceed(500.Milliseconds());
Alternatively, to verify the execution time of an arbitrary action, use this syntax:
Action someAction = () => Thread.Sleep(510);
someAction.ExecutionTime().ShouldNotExceed(100.Milliseconds());
Since it doesn’t make sense to do something like that in Silverlight, it is only available in the .NET 3.5 and .NET 4.0 versions of Fluent Assertions.
Make sure to set a sensible execution limit – bear in mind who’s running the tests (might be slow hardware – false negatives ahoy). It’s considered polite to put a Category attribute with a “Slow” value so people can exclude long running integration tests.







