public void NullObservablesDoNotCauseExceptions()
        {
            var fixture = new TestWhenAnyObsViewModel();

            fixture.Command1 = null;

            // these are the overloads of WhenAnyObservable that perform a Merge
            fixture.WhenAnyObservable(x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();

            // these are the overloads of WhenAnyObservable that perform a CombineLatest
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, (_0, _1) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, (_0, _1, _2) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (_0, _1, _2, _3) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (_0, _1, _2, _3, _4) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (_0, _1, _2, _3, _4, _5) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (_0, _1, _2, _3, _4, _5, _6) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (_0, _1, _2, _3, _4, _5, _6, _7) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (_0, _1, _2, _3, _4, _5, _6, _7, _8) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) => Unit.Default).Subscribe();
        }
        public async Task WhenAnyObservableSmokeTestCombining()
        {
            var fixture = new TestWhenAnyObsViewModel();

            var list = new List <string>();

            fixture.WhenAnyObservable(x => x.Command3, x => x.Command1, (s, i) => s + " : " + i)
            .Subscribe(list.Add);

            Assert.Equal(0, list.Count);

            await fixture.Command1.Execute(1);

            await fixture.Command3.Execute("foo");

            Assert.Equal(1, list.Count);

            await fixture.Command1.Execute(2);

            Assert.Equal(2, list.Count);

            await fixture.Command3.Execute("bar");

            Assert.Equal(3, list.Count);

            Assert.True(
                new[] { "foo : 1", "foo : 2", "bar : 2", }.Zip(list, (expected, actual) => new { expected, actual })
                .All(x => x.expected == x.actual));
        }
        public async Task WhenAnyObservableSmokeTestMerging()
        {
            var fixture = new TestWhenAnyObsViewModel();

            var list = new List <int>();

#pragma warning disable CS8603 // Possible null reference return.
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command2).ObserveOn(ImmediateScheduler.Instance).Subscribe(list.Add);
#pragma warning restore CS8603 // Possible null reference return.

            Assert.Equal(0, list.Count);

            await fixture.Command1 !.Execute(1);
            Assert.Equal(1, list.Count);

            await fixture.Command2.Execute(2);

            Assert.Equal(2, list.Count);

            await fixture.Command1.Execute(1);

            Assert.Equal(3, list.Count);

            Assert.True(
                new[] { 1, 2, 1, }.Zip(
                    list,
                    (expected, actual) => new
            {
                expected,
                actual
            }).All(x => x.expected == x.actual));
        }
        public async Task WhenAnyObservableSmokeTestMerging()
        {
            var fixture = new TestWhenAnyObsViewModel();

            var list = new List <int>();

            fixture.WhenAnyObservable(x => x.Command1, x => x.Command2)
            .Subscribe(list.Add);

            Assert.Equal(0, list.Count);

            await fixture.Command1.Execute(1);

            Assert.Equal(1, list.Count);

            await fixture.Command2.Execute(2);

            Assert.Equal(2, list.Count);

            await fixture.Command1.Execute(1);

            Assert.Equal(3, list.Count);

            Assert.True(
                new[] { 1, 2, 1, }.Zip(list, (expected, actual) => new { expected, actual })
                .All(x => x.expected == x.actual));
        }
        public async Task WhenAnyObservableSmokeTestCombining()
        {
            var fixture = new TestWhenAnyObsViewModel();

            var list = new List <string>();

#pragma warning disable CS8603 // Possible null reference return.
            fixture.WhenAnyObservable(x => x.Command3, x => x.Command1, (s, i) => s + " : " + i).ObserveOn(ImmediateScheduler.Instance).Subscribe(list.Add);
#pragma warning restore CS8603 // Possible null reference return.

            Assert.Equal(0, list.Count);

            await fixture.Command1 !.Execute(1);
            await fixture.Command3.Execute("foo");

            Assert.Equal(1, list.Count);

            await fixture.Command1.Execute(2);

            Assert.Equal(2, list.Count);

            await fixture.Command3.Execute("bar");

            Assert.Equal(3, list.Count);

            Assert.True(
                new[] { "foo : 1", "foo : 2", "bar : 2", }.Zip(
                    list,
                    (expected, actual) => new
            {
                expected,
                actual
            }).All(x => x.expected == x.actual));
        }
        public void NullObservablesDoNotCauseExceptions()
        {
            var fixture = new TestWhenAnyObsViewModel();

            fixture.Command1 = null;

            // these are the overloads of WhenAnyObservable that perform a Merge
#pragma warning disable CS8603 // Possible null reference return.
            fixture.WhenAnyObservable(x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();

            // these are the overloads of WhenAnyObservable that perform a CombineLatest
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, (zero, one) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, (zero, one, two) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (zero, one, two, three) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (zero, one, two, three, four) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (zero, one, two, three, four, five) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (zero, one, two, three, four, five, six) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (zero, one, two, three, four, five, six, seven) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (zero, one, two, three, four, five, six, seven, eight) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (zero, one, two, three, four, five, six, seven, eight, nine) => Unit.Default).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, (zero, one, two, three, four, five, six, seven, eight, nine, ten) => Unit.Default).Subscribe();
#pragma warning restore CS8603 // Possible null reference return.
        }
        public void WhenAnyObservableWithNullObjectShouldUpdateWhenObjectIsntNullAnymore()
        {
            var fixture = new TestWhenAnyObsViewModel();
            var output  = fixture.WhenAnyObservable(x => x.MyListOfInts.CountChanged).CreateCollection();

            Assert.Equal(0, output.Count);

            fixture.MyListOfInts = new ReactiveList <int>();
            Assert.Equal(0, output.Count);

            fixture.MyListOfInts.Add(1);
            Assert.Equal(1, output.Count);

            fixture.MyListOfInts = null;
            Assert.Equal(1, output.Count);
        }
Esempio n. 8
0
        public void WhenAnyObservableWithNullObjectShouldUpdateWhenObjectIsntNullAnymore()
        {
            var fixture = new TestWhenAnyObsViewModel();

            fixture !.WhenAnyObservable(x => x.Changes) !.Bind(out var output).ObserveOn(ImmediateScheduler.Instance).Subscribe();
            Assert.Equal(0, output.Count);

            fixture.MyListOfInts = new ObservableCollectionExtended <int>();
            Assert.Equal(0, output.Count);

            fixture.MyListOfInts.Add(1);
            Assert.Equal(1, output.Count);

            fixture.MyListOfInts = null;
            Assert.Equal(1, output.Count);
        }
Esempio n. 9
0
        public void NullObservablesDoNotCauseExceptions()
        {
            var fixture = new TestWhenAnyObsViewModel();

            fixture.Command1 = null;

            fixture.WhenAnyObservable(x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
            fixture.WhenAnyObservable(x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1, x => x.Command1).Subscribe();
        }
        public void WhenAnyObservableWithNullObjectShouldUpdateWhenObjectIsntNullAnymore()
        {
            var fixture = new TestWhenAnyObsViewModel();

#pragma warning disable CS8603 // Possible null reference return.
            fixture.WhenAnyObservable(x => x.Changes).Bind(out var output).ObserveOn(ImmediateScheduler.Instance).Subscribe();
#pragma warning restore CS8603 // Possible null reference return.

            Assert.Equal(0, output.Count);

            fixture.MyListOfInts = new ObservableCollectionExtended <int>();
            Assert.Equal(0, output.Count);

            fixture.MyListOfInts.Add(1);
            Assert.Equal(1, output.Count);

            fixture.MyListOfInts = null;
            Assert.Equal(1, output.Count);
        }