daily pastebin goal
89%
SHARE
TWEET

Untitled

a guest Jan 18th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. [TestMethod]
  2.    public void DoSomeWork_WhenWeDoSomeWork_ShouldReturnDone()
  3.    {
  4.       var service = new SyncService();
  5.  
  6.       const string expected = "Done";
  7.       var actual = service.DoSomeWork();
  8.  
  9.       Assert.AreEqual(expected, actual);
  10.  
  11.    }
  12.    
  13. public ActionResult Index()
  14.     {
  15.        var syncService = new SyncService();
  16.  
  17.         return View((object)syncService.DoSomeWork());
  18.     }
  19.    
  20. public class SyncService
  21.     {
  22.        public string DoSomeWork()
  23.        {
  24.           return SomeWork().GetAwaiter().GetResult();
  25.        }
  26.  
  27.        private async Task<string> SomeWork()
  28.        {
  29.           var task1 = Task.Delay(1000);
  30.           var task2 = Task.Delay(1000);
  31.  
  32.           await Task.WhenAll(task1, task2);
  33.  
  34.           return "Done";
  35.        }
  36.     }
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