public void TrackWorkloadThrowsOnNullTracker() { // arrange IAutoTracker tracker = null; Action workload = null; // act var ex = Assert.Throws <ArgumentNullException>(() => tracker.Track(workload)); // assert Assert.Equal(nameof(tracker), ex.ParamName); }
public void TrackWorkloadWithScopeAndResultThrowsOnNullTracker() { // arrange IAutoTracker tracker = null; Func <ITrackingScope, int> workload = null; // act var ex = Assert.Throws <ArgumentNullException>(() => tracker.Track(workload)); // assert Assert.Equal(nameof(tracker), ex.ParamName); }
/// <inheritdoc cref="IAutoTracker.Track{TResult}(Func{ITrackingScope, CancellationToken, TResult}, CancellationToken)"/> public static TResult Track <TResult>(this IAutoTracker tracker, Func <TResult> workload) { if (tracker is null) { throw new ArgumentNullException(nameof(tracker)); } if (workload is null) { throw new ArgumentNullException(nameof(workload)); } return(tracker.Track((scope, token) => workload())); }
/// <inheritdoc cref="IAutoTracker.Track(Action{ITrackingScope, CancellationToken}, CancellationToken)"/> public static void Track(this IAutoTracker tracker, Action workload) { if (tracker is null) { throw new ArgumentNullException(nameof(tracker)); } if (workload is null) { throw new ArgumentNullException(nameof(workload)); } tracker.Track((scope, token) => workload()); }