Exemple #1
0
        public void LiveObservableBaseListCollectionException([ValueSource("SchedulersToTest")] IScheduler scheduler)
        {
            mockBaseList.Count.Returns(c => throw new InvalidOperationException());

            var obs = mockBaseList.ToObservable(ObservableType.LiveUpdating, scheduler);

            Assert.Throws <InvalidOperationException>(() =>
            {
                obs.Wait();
            });
        }
Exemple #2
0
        public void ToObservableBaseListCollectionNull([Values] ObservableType type)
        {
            IBaseListCollection <int> list = null;

            Assert.Throws <ArgumentNullException>(() =>
            {
                list.ToObservable(type);
            });
        }
Exemple #3
0
        /// <summary>
        /// Convert a <see cref="IBaseListCollection{T}"/> into an <see cref="IObservable{T}"/> of a specific type.
        /// </summary>
        /// <typeparam name="T">Type of data.</typeparam>
        /// <param name="source">Source data.</param>
        /// <param name="type">What type of observable should be created.</param>
        /// <returns>An <see cref="IObservable{T}"/> based off the <paramref name="source"/>.</returns>
        public static IObservable <T> ToObservable <T>(this IBaseListCollection <T> source, ObservableType type)
        {
            if (source == null)
            {
                throw new ArgumentNullException(nameof(source));
            }
            if (type == ObservableType.Traditional)
            {
                // System.Reactive, at the time of this writing, uses CurrentThreadScheduler.Instance for the scheduler.
                // But in case that changes in the future, let the default ToObservable run instead of passing in the scheduler
                return(System.Reactive.Linq.Observable.ToObservable(source));
            }

            return(source.ToObservable(type, CurrentThreadScheduler.Instance));
        }