Wait until all Task finish in unit test
问题 I have this class I want to unit test: public class SomeClass { public void Foo() { Bar(); } private void Bar() { Task.Factory.StartNew(() => { // Do something that takes some time (e.g. an HTTP request) }); } } And this is how my unit test looks like: [TestMethod] public void TestFoo() { // Arrange var obj = new SomeClass(); // Act obj.Foo(); obj.Foo(); obj.Foo(); // Assert /* I need something to wait on all tasks to finish */ Assert.IsTrue(...); } So, I need to make the unit test thread