예제 #1
0
        public void ArgumentNullExceptionTest()
        {
            var loop = new UvLoop();

            Assert.Throws <ArgumentNullException>(() => new UvAsync(null, async => { }));
            Assert.Throws <ArgumentNullException>(() => new UvAsync(loop, null));

            loop.Close();
        }
예제 #2
0
        public void AsyncCallbackTet()
        {
            var callbackCallCount = 0;
            var loop  = new UvLoop();
            var async = new UvAsync(loop, thisAsync =>
            {
                callbackCallCount++;
                thisAsync.Close();
            });

            Assert.Equal(0, callbackCallCount);

            loop.Run(UvLoopRunMode.RunNowait);
            Assert.Equal(0, callbackCallCount);

            new Thread(() => { async.Send(); }).Start();
            Assert.Equal(0, callbackCallCount);

            loop.Run();
            loop.Close();

            Assert.Equal(1, callbackCallCount);
        }