1
我有一個單元測試,測試BufferWithTime。我似乎得到不一致的結果,當值在該點的緩衝會發出新的價值被髮射。不一致BufferWithTime行爲
var scheduler = new TestScheduler();
var source = scheduler.CreateColdObservable(
new Recorded<Notification<int>>(50, new Notification<int>.OnNext(1)),
new Recorded<Notification<int>>(100, new Notification<int>.OnNext(2)),
new Recorded<Notification<int>>(150, new Notification<int>.OnNext(3)),
new Recorded<Notification<int>>(200, new Notification<int>.OnNext(4)),
new Recorded<Notification<int>>(250, new Notification<int>.OnNext(5)),
new Recorded<Notification<int>>(300, new Notification<int>.OnNext(6)),
new Recorded<Notification<int>>(350, new Notification<int>.OnNext(7)),
new Recorded<Notification<int>>(400, new Notification<int>.OnNext(8)),
new Recorded<Notification<int>>(450, new Notification<int>.OnNext(9)),
new Recorded<Notification<int>>(450, new Notification<int>.OnCompleted()));
var results = scheduler.Run(() => source
.BufferWithTime(TimeSpan.FromTicks(150), scheduler));
結果我回來從這個本質:
results[0] = [1,2]
results[1] = [3,4,5,6]
results[2] = [7,8,9]
我的問題是,爲什麼會出現在第一緩衝只有兩個項目,4個在第二?我預計它發射的緩衝是應該發生的同一時間源,他們要麼總是在緩衝區或總是排隊等待下一個緩衝區。我剛剛偶然發現了一個錯誤?
聽起來像它可能涉及到的方式TestScheduler時間表「立即」行動,爲1蜱未來的行動。可能要問在論壇上 - http://social.msdn.microsoft.com/Forums/en-US/rx/threads – 2011-03-10 15:08:09