using Quadarax.Foundation.Core.Thread.Extensions;

namespace qdr.fnd.core.test.Thread
{
    public class TaskExtTest
    {
        [Test(TestOf = typeof(TaskExt))]
        public void TimeoutAfterOk()
        {
            var task = Task.Run(() => Task.Delay(1000));
            var timeout = TimeSpan.FromMilliseconds(500);
            var ex = Assert.Throws<AggregateException>(() => task.TimeoutAfter(timeout).Wait());
            Assert.That(ex.InnerException, Is.InstanceOf<TimeoutException>());

            var timeout2 = TimeSpan.FromMilliseconds(1500);
            task.TimeoutAfter(timeout2).Wait();
        }
    }
}
