public void TestCoroProducerMultipleConsumer() { var kernel = Create.NewKernel(); var prod = kernel.Factory.NewCoroutine(Producer); var channel = kernel.Factory.NewChannel(prod); var con1 = new Consumer(kernel, channel); var con2 = new Consumer(kernel, channel); StepKernel(kernel, 50); Assert.AreEqual(15, con1.Sum + con2.Sum); }
public void TestProducerConsumer() { var kernel = Create.NewKernel(); var channel = kernel.Factory.NewChannel<int>(); var con = new Consumer(kernel, channel); channel.Insert(1); StepKernel(kernel, 5); Assert.AreEqual(1, con.Sum); channel.Insert(1); StepKernel(kernel, 5); Assert.AreEqual(2, con.Sum); channel.Insert(1); StepKernel(kernel, 5); Assert.AreEqual(3, con.Sum); StepKernel(kernel, 5); Assert.AreEqual(3, con.Sum); }