Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [TestMethod]
- public void DoSomeWork_WhenWeDoSomeWork_ShouldReturnDone()
- {
- var service = new SyncService();
- const string expected = "Done";
- var actual = service.DoSomeWork();
- Assert.AreEqual(expected, actual);
- }
- public ActionResult Index()
- {
- var syncService = new SyncService();
- return View((object)syncService.DoSomeWork());
- }
- public class SyncService
- {
- public string DoSomeWork()
- {
- return SomeWork().GetAwaiter().GetResult();
- }
- private async Task<string> SomeWork()
- {
- var task1 = Task.Delay(1000);
- var task2 = Task.Delay(1000);
- await Task.WhenAll(task1, task2);
- return "Done";
- }
- }
Add Comment
Please, Sign In to add comment