コード例 #1
0
ファイル: LongRunningTests.cs プロジェクト: slieser/sandbox
        public void Naiv() {
            var sut = new LongRunning();
            string result = null;
            sut.Result += x => result = x;

            sut.GetResultAsync();

            Assert.That(result, Is.EqualTo("Hello"));
        }
コード例 #2
0
ファイル: LongRunningTests.cs プロジェクト: slieser/sandbox
        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"));
        }