public void Naiv() { var sut = new LongRunning(); string result = null; sut.Result += x => result = x; sut.GetResultAsync(); Assert.That(result, Is.EqualTo("Hello")); }
public void Schon_besser() { var sut = new LongRunning(); var autoResetEvent = new AutoResetEvent(false); string result = null; sut.Result += x => { result = x; autoResetEvent.Set(); }; sut.GetResultAsync(); Assert.That(autoResetEvent.WaitOne(5000), Is.True); Assert.That(result, Is.EqualTo("Hello")); }
public void Aspekte_sind_zu_trennen() { var asyncer = new Asynchronizer<string>(); var sut = new LongRunning(); var autoResetEvent = new AutoResetEvent(false); string result = null; asyncer.Result += x => { result = x; autoResetEvent.Set(); }; asyncer.Process(sut.GetResult); Assert.That(autoResetEvent.WaitOne(5000), Is.True); Assert.That(result, Is.EqualTo("Hello")); }