Esempio n. 1
0
        public async Task Test1()
        {
            var wrapper = new WrapperErrorHandling <TestErrorHandlingWrapperService>(
                new WrapperErrorHandlingSettings()
            {
                AdvancedErrorHandling = (x, y) => { throw y; }
            },
                new TestErrorHandlingWrapperService()
                );
            var proxy = wrapper.GetProxy();

            //
            try
            {
                proxy.TestException();
            }
            catch (Exception exc)
            {
                if (exc.GetType() != typeof(Exception) || exc.Message != "Test")
                {
                    throw new InvalidOperationException("Test");
                }
            }
            //
            try
            {
                proxy.TestException1();
            }
            catch (Exception exc)
            {
                if (exc.GetType() != typeof(Exception) || exc.Message != "Test1")
                {
                    throw new InvalidOperationException("Test1");
                }
            }
            //
            try
            {
                await proxy.TestException2().ConfigureAwait(false);
            }
            catch (Exception exc)
            {
                if (exc.GetType() != typeof(Exception) || exc.Message != "Test2")
                {
                    throw new InvalidOperationException("Test2");
                }
            }
            //
            try
            {
                await proxy.TestException3().ConfigureAwait(false);
            }
            catch (Exception exc)
            {
                if (exc.GetType() != typeof(Exception) || exc.Message != "Test3")
                {
                    throw new InvalidOperationException("Test3");
                }
            }
        }
 public async Task Test1()
 {
     var wrapper = new WrapperErrorHandling<TestErrorHandlingWrapperService>(
         new WrapperErrorHandlingSettings()
         {
             AdvancedErrorHandling = (x, y) => { throw y; }
         },
         new TestErrorHandlingWrapperService()
     );
     var proxy = wrapper.GetProxy();
     //
     try
     {
         proxy.TestException();
     }
     catch (Exception exc)
     {
         if(exc.GetType() != typeof(Exception) || exc.Message != "Test")
             throw new InvalidOperationException("Test");
     }
     //
     try
     {
         proxy.TestException1();
     }
     catch (Exception exc)
     {
         if (exc.GetType() != typeof(Exception) || exc.Message != "Test1")
             throw new InvalidOperationException("Test1");
     }
     //
     try
     {
         await proxy.TestException2().ConfigureAwait(false);
     }
     catch (Exception exc)
     {
         if (exc.GetType() != typeof(Exception) || exc.Message != "Test2")
             throw new InvalidOperationException("Test2");
     }
     //
     try
     {
         await proxy.TestException3().ConfigureAwait(false);
     }
     catch (Exception exc)
     {
         if (exc.GetType() != typeof(Exception) || exc.Message != "Test3")
             throw new InvalidOperationException("Test3");
     }
 }