Exemplo n.º 1
0
        public async Task Cancel_Dequeues_Wait_And_Cancels_Task()
        {
            using (var waiter = new Waiter())
            {
                var key  = new WaitKey(MessageCode.Server.Login);
                var task = waiter.Wait(key);

                waiter.Cancel(key);

                var ex = await Record.ExceptionAsync(() => task);

                var waits = waiter.GetProperty <ConcurrentDictionary <WaitKey, ConcurrentQueue <PendingWait> > >("Waits");

                Assert.NotNull(ex);
                Assert.IsType <TaskCanceledException>(ex);

                Assert.False(waits.TryGetValue(key, out _));
            }
        }