Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        /// <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()));
        }
Exemplo n.º 4
0
        /// <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());
        }