internal void InvokeMeasured_ThrowsAnException_WhenActionIsNull(IProfiler profiler) { var exception = Assert.Throws <ArgumentNullException>(() => profiler.InvokeMeasured( _instance, null)); Assert.Equal("action", exception.ParamName); }
internal void InvokeMeasured_DoesNotThrowAnException_WhenInstanceIsNull(IProfiler profiler) { var result = profiler.InvokeMeasured((object)null, x => { Assert.Null(x); return(true); }); Assert.True(result); }
internal void InvokeMeasured_ReturnsResult_ForFunctions(IProfiler profiler) { var result = profiler.InvokeMeasured(_instance, x => { Assert.Same(_instance, x); return(x.ToString()); }); Assert.Equal(_instance.ToString(), result); }
internal void InvokeMeasured_WithActionAndNullInstance_InvokesIt(IProfiler profiler) { var invoked = false; profiler.InvokeMeasured((object)null, x => { Assert.Null(x); invoked = true; }); Assert.True(invoked); }
internal void InvokeMeasured_WithAction_InvokesIt(IProfiler profiler) { var invoked = false; profiler.InvokeMeasured(_instance, x => { Assert.Same(_instance, x); invoked = true; }); Assert.True(invoked); }
public static void InvokeMeasured <TInstance>( [NotNull] this IProfiler profiler, [CanBeNull] TInstance instance, [NotNull] Action <TInstance> action, [CanBeNull] string message = null) { if (profiler == null) { throw new ArgumentNullException(nameof(profiler)); } if (action == null) { throw new ArgumentNullException(nameof(action)); } profiler.InvokeMeasured(new InstanceAction <TInstance>(instance, action), InvokeAction, message); }