Exemple #1
0
        public void TestCallAsyncFireAndForget_Completed()
        {
            try
            {
                // output "hello world" as method returns early
                ASSERT.AreEqual(ExampleFireAndForgetFunc(() =>
                {
                    Thread.Sleep(100);
                    return(false);  // don't throw exception
                }), "hello world");
            }
            catch
            {
                // Exception is NOT caught here
                ASSERT.Fail("exception should not be caught here");
            }
            ASSERT.IsNull(caught_ex);

            Thread.Sleep(500);

            ASSERT.IsNull(caught_ex);
            ASSERT.IsFalse(faulted, "faulted");
            ASSERT.IsTrue(completed, "completed");
            ASSERT.IsFalse(canceled, "cancelled");
        }
Exemple #2
0
        public void TestCallAsyncFireAndForget_Canceled()
        {
            try
            {
                var cts = new CancellationTokenSource(400);

                // output "hello world" as method returns early
                ASSERT.AreEqual(ExampleFireAndForgetFunc(() =>
                {
                    while (!cts.Token.IsCancellationRequested)
                    {
                        Thread.Sleep(20);
                    }
                    cts.Token.ThrowIfCancellationRequested();
                    return(false);  // don't throw exception
                }), "hello world");
            }
            catch
            {
                // Exception is NOT caught here
                ASSERT.Fail("exception should not be caught here");
            }
            ASSERT.IsNull(caught_ex);

            Thread.Sleep(500);

            ASSERT.IsNull(caught_ex);
            ASSERT.IsFalse(faulted, "faulted");
            ASSERT.IsTrue(completed, "completed");
            ASSERT.IsTrue(canceled, "cancelled");
        }
Exemple #3
0
        public void TestCallAsyncFireAndForget_ImmediateThrow()
        {
            try
            {
                // output "hello world" as method returns early
                ASSERT.AreEqual(ExampleFireAndForgetFunc(), "hello world");
            }
            catch
            {
                // Exception is NOT caught here
                ASSERT.Fail("exception should not be caught here");
            }
            //ASSERT.IsNull(caught_ex);

            Thread.Sleep(500);

            ASSERT.IsNotNull(caught_ex);
            ASSERT.IsTrue(faulted, "faulted");
            ASSERT.IsTrue(completed, "completed");
            ASSERT.IsFalse(canceled, "cancelled");
        }
 public void TEST_Has_Not_Been_Defined_In_The_Project_Configuration()
 {
     ASSERT.Fail("TEST has not been defined in the QiqqaSystemTester project configuration.");
 }