SHARE
TWEET

Untitled

a guest Aug 25th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public async Task Test1()
  2.         {
  3.  
  4.             var exception = await RunAvaloniaTest(async () =>
  5.             {
  6.                 var clipboard = Application.Current.Clipboard;
  7.  
  8.                 await clipboard.SetTextAsync("Test").ConfigureAwait(true);
  9.  
  10.                 var text = await clipboard.GetTextAsync().ConfigureAwait(true);
  11.  
  12.                 Assert.Equal("", "123");
  13.  
  14.                 int y = 2;
  15.             });
  16.  
  17.             if(exception != null)
  18.             {
  19.                 throw exception;
  20.             }
  21.                
  22.         }
  23.  
  24.         public static async Task<Exception> RunAvaloniaTest(Action testCode)
  25.         {
  26.             var tcs = new TaskCompletionSource<Exception>();
  27.  
  28.             BuildAvaloniaApp().Start(async (app, args) =>
  29.             {
  30.                 try
  31.                 {
  32.                     testCode();
  33.                 }
  34.                 catch (Exception e)
  35.                 {
  36.                     tcs.SetResult(e);
  37.  
  38.                     return;
  39.                 }
  40.  
  41.                 tcs.SetResult(null);
  42.             }, null);
  43.  
  44.             return await tcs.Task;
  45.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top