Ejemplo n.º 1
0
        public async Task Test_await_Task()
        {
            var sut = new Concurrency();
            // async/await pattern is recommended over 'blocking' methods.
            // but it forces to reimplement all blocking methods as they return Task or Task<T> type.
            await sut.SayAsync("Hi", TimeSpan.FromMilliseconds(5));

            // you can also  mix Task.Run and blocking method though, it is not recommended.
            // await Task.Run(() => sut.Say("Hi", TimeSpan.FromMilliseconds(5)));

            var output = sut.Logs.ToArray();

            Assert.True(output.All(message => message == "Hi"));
        }