public void TriggerTest()
        {
            var baseline        = new System.Reactive.Subjects.BehaviorSubject <int>(0);
            var outerCollection = new ObservableCollection <Observable>(Enumerable.Range(1, 10).Select(i => new Observable(2 * i + 1)));
            var innerCollection = new ObservableCollection <Notify>(Enumerable.Range(1, 10).Select(i => new Notify {
                Prop = i
            }));
            var ijrooc = new InnerJoinReadOnlyObservableCollection <Observable, Notify, int, int>(outerCollection, innerCollection,
                                                                                                  x => x.Subject, x => x.ObserveAll().Select(i => i.Prop), (x, y) => baseline.Select(v => v + x.Prop + y.Prop));
            var copy = ijrooc.ListSelect(x => x);

            outerCollection[8].Prop = 4;
            innerCollection[8].Prop = 0;

            var expectedValues = new HashSet <int>(
                from x in outerCollection join y in innerCollection on x.Prop equals y.Prop select x.Prop + y.Prop);

            Assert.IsTrue(expectedValues.SetEquals(ijrooc));
            Assert.IsTrue(expectedValues.SetEquals(copy));

            baseline.OnNext(2);

            expectedValues = new HashSet <int>(
                from x in outerCollection join y in innerCollection on x.Prop equals y.Prop select x.Prop + y.Prop + baseline.Value);
            Assert.IsTrue(expectedValues.SetEquals(ijrooc));
            Assert.IsTrue(expectedValues.SetEquals(copy));
        }
Exemplo n.º 2
0
        public void TriggerTest()
        {
            var baseline        = new System.Reactive.Subjects.BehaviorSubject <int>(0);
            var outerCollection = new ObservableCollection <Observable>(Enumerable.Range(1, 10).Select(i => new Observable(2 * i + 1)));
            var innerCollection = new ObservableCollection <Notify>(Enumerable.Range(1, 5).Select(i => new Notify {
                Prop = i
            }));
            var zrool = new ZipReadOnlyObservableList <Observable, Notify, int>(outerCollection, innerCollection,
                                                                                (x, y) => x.Subject.CombineLatest(y.ObserveAll().Select(b => b.Prop), (a, b) => a + b).CombineLatest(baseline, (a, b) => a + b));
            var copy = zrool.ListSelect(x => x);

            outerCollection[8].Prop = 4;
            innerCollection[2].Prop = 0;
            outerCollection[3].Prop = 100;

            var expectedValues = new HashSet <int>(outerCollection.Zip(innerCollection, (x, y) => x.Prop + y.Prop + baseline.Value));

            Assert.IsTrue(expectedValues.SetEquals(zrool));
            Assert.IsTrue(expectedValues.SetEquals(copy));

            baseline.OnNext(2);

            expectedValues = new HashSet <int>(outerCollection.Zip(innerCollection, (x, y) => x.Prop + y.Prop + baseline.Value));
            Assert.IsTrue(expectedValues.SetEquals(zrool));
            Assert.IsTrue(expectedValues.SetEquals(copy));
        }
Exemplo n.º 3
0
        public void OnFrame()
        {
            frameCount += 1;
            var elapsedTime = stopwatch.ElapsedTicks / System.Diagnostics.Stopwatch.Frequency;

            if (elapsedTime >= 1f)
            {
                var fps = (double)frameCount / elapsedTime;
                Fps.OnNext(fps);
                frameCount = 0;
                stopwatch.Restart();
            }
        }