Guest User

Untitled

a guest
Jan 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  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. }
Add Comment
Please, Sign In to add comment