Exemple #1
0
        public void Multiple()
        {
            var ms = new MaybeSubject <int>();

            var source = ms.Cache();

            var to1 = source.Test();
            var to2 = source.Test();
            var to3 = source.Test(true);

            ms.OnSuccess(1);

            to1.AssertResult(1);
            to2.AssertResult(1);
            to3.AssertEmpty();
        }
Exemple #2
0
        public void Dispose_Run_Cancel()
        {
            var ms     = new MaybeSubject <int>();
            var cancel = new IDisposable[1];

            var source = ms.Cache(d => cancel[0] = d);

            Assert.Null(cancel[0], "cancel set?");
            Assert.False(ms.HasObserver(), "has observers?");

            var to = source.Test(true);

            Assert.NotNull(cancel[0], "cancel not set?");
            Assert.True(ms.HasObserver(), "no observers?");

            cancel[0].Dispose();
            cancel[0].Dispose();

            to.AssertEmpty();

            source.Test().AssertFailure(typeof(OperationCanceledException));

            Assert.False(ms.HasObserver(), "still observers?");
        }