示例#1
0
 public void ToBe(
     string marbles,
     Exception error = null)
 {
     Ensure.NotNull(marbles, nameof(marbles));
     _expectation.HandleToBe(marbles, Marbles.ToNotifications(marbles, error));
 }
示例#2
0
        private ObservableExpectation <T> CreateExpectation <T>(IObservable <T> observable, string unsubscriptionMarbles)
        {
            var expectation         = new ObservableExpectation <T>();
            var unsubscriptionFrame = unsubscriptionMarbles != null
                ? Marbles.ToSubscription(unsubscriptionMarbles).Unsubscribe
                : Subscription.Infinite;

            IDisposable disposable = null;

            this.ScheduleAbsolute(0, () =>
            {
                disposable = observable.Subscribe(
                    x =>
                {
                    expectation.AddNotification(Clock, Notification.CreateOnNext(x));
                },
                    err => expectation.AddNotification(Clock, Notification.CreateOnError <T>(err)),
                    () => expectation.AddNotification(Clock, Notification.CreateOnCompleted <T>()));
            });
            if (unsubscriptionFrame != Subscription.Infinite)
            {
                this.ScheduleAbsolute(unsubscriptionFrame, () => disposable.Dispose());
            }
            return(expectation);
        }
示例#3
0
        public ITestableObservable <char> Hot(
            string marbles,
            Exception error = null)
        {
            Ensure.NotNull(marbles, nameof(marbles));
            var messages = Marbles.ToNotifications(marbles, error);

            return(new HotObservable <char>(this, messages));
        }
示例#4
0
        public ITestableObservable <T> Hot <T>(
            string marbles,
            IReadOnlyDictionary <char, T> values,
            Exception error = null)
        {
            Ensure.NotNull(marbles, nameof(marbles));
            Ensure.NotNull(values, nameof(values));
            Ensure.NotContainsMarkers(values, nameof(values));
            var messages = Marbles.ToNotifications(marbles, values, error);

            return(new HotObservable <T>(this, messages));
        }