Exemplo n.º 1
0
Arquivo: Test.cs Projeto: net-ba/tpl
        public void StoreResult_Cancel_Negative1IsStored()
        {
            IDisposable disposableToken = null;

            try
            {
                var implement = new Implement();
                var storage   = new Storage();

                TaskResponse response = implement.CreateTask(70);
                disposableToken = response.CancelProvider;
                implement.StoreResult(response.Task, storage);

                Thread.Sleep(100);
                response.CancelProvider.Cancel();

                Thread.Sleep(100);
                Assert.Equal(-1, storage.Value);
            }
            finally
            {
                if (disposableToken != null)
                {
                    disposableToken.Dispose();
                }
            }
        }
Exemplo n.º 2
0
Arquivo: Test.cs Projeto: net-ba/tpl
        public void StoreResult_60_60IsStored()
        {
            IDisposable disposableToken = null;

            try
            {
                var implement = new Implement();
                var storage   = new Storage();

                TaskResponse response = implement.CreateTask(60);
                disposableToken = response.CancelProvider;
                implement.StoreResult(response.Task, storage);

                Assert.NotEqual(60, storage.Value);
                Thread.Sleep(400);
                Assert.NotEqual(60, storage.Value);
                Thread.Sleep(200);
                Assert.Equal(60, storage.Value);
            }
            finally
            {
                if (disposableToken != null)
                {
                    disposableToken.Dispose();
                }
            }
        }