public void ForEach_Old() { var o = new ListObservable<int>(Observable.Range(0, 10)); var l = new List<int>(); foreach (int x in (IEnumerable)o) l.Add(x); l.AssertEqual(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); }
public void Remove_None() { var o = new ListObservable<int>(Observable.Empty<int>()); Assert.AreEqual(false, o.Remove(0)); o.AssertEqual(); }
public void Remove_Some_Found() { var o = new ListObservable<int>(Observable.Range(0, 10)); Assert.AreEqual(true, o.Remove(3)); o.AssertEqual(0, 1, 2, 4, 5, 6, 7, 8, 9); }
public void Change_Error() { var o = new ListObservable <int>(Observable.Range(0, 10)); ReactiveAssert.Throws <ArgumentOutOfRangeException>(() => o[100] = -1); }
public void Add_Empty() { var o = new ListObservable<int>(Observable.Empty<int>()); o.Add(100); o.AssertEqual(100); }
public void RemoveAt_Some_NotFound() { var o = new ListObservable<int>(Observable.Range(0, 10)); ReactiveAssert.Throws<ArgumentOutOfRangeException>(() => o.RemoveAt(100)); o.AssertEqual(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); }
public void ObservableCanExecuteFuncShouldShowUpInCommand() { int counter = 1; var fixture = new ReactiveCommand(_ => (++counter % 2 == 0), null); var changes_as_observable = new ListObservable<bool>(fixture.CanExecuteObservable); int change_event_count = 0; fixture.CanExecuteChanged += (o, e) => { change_event_count++; }; Enumerable.Range(0, 6).Run(x => { Assert.AreEqual(x % 2 == 0, fixture.CanExecute(null)); }); Assert.AreEqual(6, change_event_count); }
public void This_Some_NotFound() { var o = new ListObservable <int>(Observable.Range(0, 10)); ReactiveAssert.Throws <ArgumentOutOfRangeException>(() => { var t = o[100]; }); }
public void This_Some_Found() { var o = new ListObservable <int>(Observable.Range(0, 10)); Assert.Equal(5, o[5]); }
public void IsReadOnly() { var o = new ListObservable <int>(Observable.Never <int>()); Assert.Equal(false, o.IsReadOnly); }
public void This_None() { var o = new ListObservable <int>(Observable.Empty <int>()); ReactiveAssert.Throws <ArgumentOutOfRangeException>(() => { var t = o[0]; }); }
public void Contains_Some_Found() { var o = new ListObservable <int>(Observable.Range(0, 10)); Assert.Equal(true, o.Contains(3)); }
public void Contains_Some_NotFound() { var o = new ListObservable <int>(Observable.Range(0, 10)); Assert.Equal(false, o.Contains(100)); }
public void Contains_None() { var o = new ListObservable <int>(Observable.Empty <int>()); Assert.Equal(false, o.Contains(0)); }
public void Subscribe_Disposed_Multi() { var s = new TestScheduler(); var xs = s.CreateHotObservable<int>( OnNext(300, 1), OnCompleted<int>(400) ); var o = new ListObservable<int>(xs); var results1 = s.CreateObserver<object>(); var results2 = s.CreateObserver<object>(); var d1 = o.Subscribe(results1); var d2 = o.Subscribe(results2); s.ScheduleAbsolute(350, () => d1.Dispose()); s.ScheduleAbsolute(500, () => d2.Dispose()); s.Start(); results1.Messages.AssertEqual( ); results2.Messages.AssertEqual( ); }
public void Value_None() { var o = new ListObservable <int>(Observable.Empty <int>()); ReactiveAssert.Throws <InvalidOperationException>(() => { var t = o.Value; }); }
public void IndexOf_None() { var o = new ListObservable<int>(Observable.Empty<int>()); Assert.AreEqual(-1, o.IndexOf(0)); }
public void Value_Some() { var o = new ListObservable <int>(Observable.Range(0, 10)); Assert.Equal(9, o.Value); }
public void Insert_Invalid_2() { var o = new ListObservable<int>(Observable.Range(0, 10)); ReactiveAssert.Throws<ArgumentOutOfRangeException>(() => o.Insert(-1, 100)); o.AssertEqual(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); }
public void IndexOf_None() { var o = new ListObservable <int>(Observable.Empty <int>()); Assert.Equal(-1, o.IndexOf(0)); }
public void ObservableCanExecuteFuncShouldShowUpInCommand() { int counter = 1; var sched = new TestScheduler(); var fixture = ReactiveCommand.Create(_ => (++counter % 2 == 0), null, sched); var changes_as_observable = new ListObservable<bool>(fixture.CanExecuteObservable); int change_event_count = 0; fixture.CanExecuteChanged += (o, e) => { change_event_count++; }; Enumerable.Range(0, 6).Run(x => { sched.Run(); this.Log().InfoFormat("Counter = {0}, x = {1}", counter, x); Assert.AreEqual(x % 2 == 0, fixture.CanExecute(null)); }); sched.Run(); Assert.AreEqual(6, change_event_count); }
public void IndexOf_Some_Found() { var o = new ListObservable <int>(Observable.Range(0, 10)); Assert.Equal(3, o.IndexOf(3)); }
public void CopyTo_Smaller_Offset() { var o = new ListObservable<int>(Observable.Range(0, 10)); var array = new int[5]; ReactiveAssert.Throws<ArgumentException>(() => o.CopyTo(array, 3)); }
public void Contains_None() { var o = new ListObservable<int>(Observable.Empty<int>()); Assert.AreEqual(false, o.Contains(0)); }
public void Add_Some() { var o = new ListObservable<int>(Observable.Return(200)); o.Add(100); o.AssertEqual(200, 100); }
public void Contains_Some_NotFound() { var o = new ListObservable<int>(Observable.Range(0, 10)); Assert.AreEqual(false, o.Contains(100)); }
public void Remove_Some_NotFound() { var o = new ListObservable<int>(Observable.Range(0, 10)); Assert.AreEqual(false, o.Remove(100)); o.AssertEqual(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); }
public void Contains_Some_Found() { var o = new ListObservable<int>(Observable.Range(0, 10)); Assert.AreEqual(true, o.Contains(3)); }
public void ForEach() { var o = new ListObservable<int>(Observable.Range(0, 10)); var l = new List<int>(); foreach (var x in o) l.Add(x); l.AssertEqual(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); }
public void Clear() { var o = new ListObservable<int>(Observable.Range(0, 10)); o.Clear(); o.AssertEqual(); }
public void Value_None() { var o = new ListObservable<int>(Observable.Empty<int>()); ReactiveAssert.Throws<InvalidOperationException>(() => { var t = o.Value; }); }
public void IsReadOnly() { var o = new ListObservable<int>(Observable.Never<int>()); Assert.AreEqual(false, o.IsReadOnly); }
public void Value_Some() { var o = new ListObservable<int>(Observable.Range(0, 10)); Assert.AreEqual(9, o.Value); }
public void This_None() { var o = new ListObservable<int>(Observable.Empty<int>()); ReactiveAssert.Throws<ArgumentOutOfRangeException>(() => { var t = o[0]; }); }
public void IndexOf_Some_Found() { var o = new ListObservable<int>(Observable.Range(0, 10)); Assert.AreEqual(3, o.IndexOf(3)); }
public void This_Some_NotFound() { var o = new ListObservable<int>(Observable.Range(0, 10)); ReactiveAssert.Throws<ArgumentOutOfRangeException>(() => { var t = o[100]; }); }
public void RemoveAt_Some_Found() { var o = new ListObservable<int>(Observable.Range(0, 10)); o.RemoveAt(3); o.AssertEqual(0, 1, 2, 4, 5, 6, 7, 8, 9); }
public void This_Some_Found() { var o = new ListObservable<int>(Observable.Range(0, 10)); Assert.AreEqual(5, o[5]); }
public void TupleCollapsingReversedPairWithoutInitialValue() { using (var pipeline = Pipeline.Create()) { var range = Generators.Range(pipeline, 0, 10, TimeSpan.FromMilliseconds(100)); var sourceA = range.Select(x => $"A{x}"); var sourceB = range.Select(x => $"B{x}"); var sourceC = range.Select(x => $"C{x}"); var sourceD = range.Select(x => $"D{x}"); var sourceE = range.Select(x => $"E{x}"); var sourceF = range.Select(x => $"F{x}"); var sourceG = range.Select(x => $"G{x}"); var tuplesFG = sourceF.Pair(sourceG); var tuplesEFG = sourceE.Pair(tuplesFG); var tuplesDEFG = sourceD.Pair(tuplesEFG); var tuplesCDEFG = sourceC.Pair(tuplesDEFG); var tuplesBCDEFG = sourceB.Pair(tuplesCDEFG); var tuplesABCDEFG = sourceA.Pair(tuplesBCDEFG); ListObservable <ValueTuple <string, string, string, string, string, string, string> > tuples = tuplesABCDEFG.ToObservable().ToListObservable(); pipeline.Run(); // cannot validate length as above because without initial value, it is non-deterministic var results = tuples.AsEnumerable().ToArray(); // can't really validate content ordering as with Join because Pair is inherently non-deterministic foreach (var r in results) { Assert.IsTrue(r.Item1.StartsWith("A")); Assert.IsTrue(r.Item2.StartsWith("B")); Assert.IsTrue(r.Item3.StartsWith("C")); Assert.IsTrue(r.Item4.StartsWith("D")); Assert.IsTrue(r.Item5.StartsWith("E")); Assert.IsTrue(r.Item6.StartsWith("F")); Assert.IsTrue(r.Item7.StartsWith("G")); } } }
public void CopyTo_RightSize() { var o = new ListObservable<int>(Observable.Range(0, 10)); var array = new int[10]; o.CopyTo(array, 0); array.AssertEqual(0, 1, 2, 3, 4, 5, 6, 7, 8, 9); }
public void ObservableCanExecuteShouldShowUpInCommand() { var can_execute = new Subject<bool>(); var fixture = new ReactiveCommand(can_execute, null); var changes_as_observable = new ListObservable<bool>(fixture.CanExecuteObservable); var input = new[] { true, false, false, true, false, true }; int change_event_count = 0; fixture.CanExecuteChanged += (o, e) => { change_event_count++; }; input.Run(x => { can_execute.OnNext(x); Assert.AreEqual(x, fixture.CanExecute(null)); }); // N.B. We check against '5' instead of 6 because we're supposed to // suppress changes that aren't actually changes i.e. false => false can_execute.OnCompleted(); Assert.AreEqual(5, change_event_count); input.Zip(changes_as_observable.ToList(), (expected, actual) => new { expected, actual }) .Do(Console.WriteLine) .Run(x => Assert.AreEqual(x.expected, x.actual)); }
public void CopyTo_Bigger_Offset() { var o = new ListObservable<int>(Observable.Range(0, 10)); var array = new int[15]; o.CopyTo(array, 3); array.AssertEqual(0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0); }
public void ObservableCanExecuteShouldShowUpInCommand() { var input = new[] {true, false, false, true, false, true}; var result = (new TestScheduler()).With(sched => { var can_execute = new Subject<bool>(); var fixture = new ReactiveCommand(can_execute, null); var changes_as_observable = new ListObservable<bool>(fixture.CanExecuteObservable); int change_event_count = 0; fixture.CanExecuteChanged += (o, e) => { change_event_count++; }; input.Run(x => { can_execute.OnNext(x); sched.Run(); Assert.AreEqual(x, fixture.CanExecute(null)); }); // N.B. We check against '5' instead of 6 because we're supposed to // suppress changes that aren't actually changes i.e. false => false can_execute.OnCompleted(); sched.Run(); Assert.AreEqual(5, change_event_count); return changes_as_observable; }); input.AssertAreEqual(result.ToList()); }
public void IndexOf_Some_NotFound() { var o = new ListObservable <int>(Observable.Range(0, 10)); Assert.AreEqual(-1, o.IndexOf(100)); }