コード例 #1
0
ファイル: ProgressorTest.cs プロジェクト: pocketgems/Theraot
        public void ConvertedProgressor()
        {
            var source    = new Progressor <int>(new[] { 0, 1, 2, 3, 4, 5 });
            var progresor = Progressor <string> .CreateConverted(source, 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);
        }