public async Task SingularThreadTest()
        {
            var _proc = new ParallelProcessing <string, int>();
            var r = new Reader(_str); var o = new OutputWrite <string, int>();

            await _proc.SingularTask(r, o, CancellationToken.None);

            CollectionAssert.AllItemsAreUnique(o, "");
            Assert.IsTrue(o.Count > 0);
            Assert.AreEqual(o["a"], 6);
            Assert.AreEqual(o["as"], 4);
            Assert.AreEqual(o["to"], 7);
        }
예제 #2
0
        public async Task MultipleTaskTest()
        {
            var _proc = new ParallelProcessing <string, int>();
            var o     = new OutputWrite <string, int>();

            //run 100 Task parallel
            Reader[] range = Enumerable.Range(1, 100).Select(i => new Reader(_str)).ToArray();

            await _proc.MultipleTasks(range, o, CancellationToken.None);

            CollectionAssert.AllItemsAreUnique(o, "");
            Assert.IsTrue(o.Count > 0);
            Assert.AreEqual(o["a"], 600);
            Assert.AreEqual(o["as"], 400);
            Assert.AreEqual(o["to"], 700);
        }