예제 #1
0
        /// <summary>
        /// Dispatches one or more batch requests. In case of auto dispatching
        /// we just trigger an implicit dispatch which could mean to interrupt
        /// a wait delay. Whereas in a manual dispatch scenario it could mean
        /// to dispatch explicitly.
        /// </summary>
        /// <param name="dataLoader">A data loader instance.</param>
        /// <exception cref="ArgumentNullException">
        /// Throws if <paramref name="dataLoader"/> is <c>null</c>.
        /// </exception>
        public static Task DispatchAsync(this IDataLoader dataLoader)
        {
            if (dataLoader == null)
            {
                throw new ArgumentNullException(nameof(dataLoader));
            }

            return(dataLoader.DispatchAsync(CancellationToken.None));
        }
        public void DispatchAsyncDataLoaderNull()
        {
            // arrange
            IDataLoader loader = null;

            // act
            Action verify = () => loader.DispatchAsync();

            // assert
            Assert.Throws <ArgumentNullException>("dataLoader", verify);
        }