Exemplo n.º 1
0
        public void ThrowSelectMany()
        {
            bool handledError = false;

            Observe.Throw <int>(new InvalidOperationException("Epic Fail!"))
            .SelectMany(t => Observe.Return(1)).Subscribe(
                value => Assert.Fail("No exception thrown"),
                ex => { handledError = true; },
                () => Assert.Fail("No exception thrown"));
            Assert.IsTrue(handledError);
        }
Exemplo n.º 2
0
        public void Select()
        {
            int result     = 0;
            int completion = 0;

            Observe.Return(1).Select(t => t + 1).Subscribe(
                x => result = x,
                ex => { throw ex; },
                () => completion++);
            Assert.AreEqual(2, result);
            Assert.AreEqual(1, completion);
        }
Exemplo n.º 3
0
        public void Return()
        {
            int count      = 0;
            int completion = 0;

            Observe.Return(1).Subscribe(
                set => count++,
                ex => { throw ex; },
                () => completion++);

            Assert.AreEqual(1, count);
            Assert.AreEqual(1, completion);
        }
Exemplo n.º 4
0
        public Observe <PortableUnit> GetAndSaveFileAsync(Uri url, string fileName, bool overwrite)
        {
            if (!overwrite && this.storage.Exists(fileName))
            {
                return(Observe.Return(new PortableUnit()));
            }

            return(this.GetStreamAsync(url, false).Select(
                       stream =>
            {
                using (stream)
                {
                    this.storage.Save(fileName, stream);
                }

                return new PortableUnit();
            }));
        }
Exemplo n.º 5
0
 public void ToObservable()
 {
     Observe.Return(1).Subscribe(set => Assert.AreEqual(1, set), ex => { });
 }
Exemplo n.º 6
0
        public async Task AwaitPattern()
        {
            var x = await Observe.Return(1);

            Assert.AreEqual(1, x);
        }