Example #1
0
        public void CreatedFilteredConverted()
        {
            var source    = new Progressor <int>(new[] { 0, 8, 1, 8, 2, 3, 4, 8, 5 });
            var progresor = Progressor <string> .CreatedFilteredConverted(source, input => input != 8, input => input.ToString(CultureInfo.InvariantCulture));

            int indexA = 0;
            int indexB = 0;

            progresor.SubscribeAction
            (
                value =>
            {
                Assert.AreEqual(value, indexB.ToString(CultureInfo.InvariantCulture));
                indexB++;
            }
            );
            string item;

            while (progresor.TryTake(out item))
            {
                Assert.AreEqual(item, indexA.ToString(CultureInfo.InvariantCulture));
                indexA++;
            }
            Assert.AreEqual(6, indexA);
            Assert.AreEqual(indexA, indexB);
        }