using System; using System.Threading; using System.Windows; using Caliburn.Messaging; using Caliburn.Metadata; using MbUnit.Framework; namespace Tests.Caliburn.The_core_framework_can { [TestFixture(ApartmentState = ApartmentState.STA)] public class by_using_ActionInfo : DispatcherTestBase { private readonly Type presenterType = typeof(TestPresenter); [Test] public void perform_a_rescue() { PresenterInfo presenterInfo = PresenterInfo.Create(presenterType); ActionInfo actionInfo = presenterInfo.FindAction("TestAction"); TestPresenter presenter = new TestPresenter(); actionInfo.PerformRescue(presenter, new Exception()); Assert.IsTrue(presenter.ActionRescueCalled); } [Test] public void execute_a_method() { ExecuteWithDispatcher( delegate { PresenterInfo presenterInfo = PresenterInfo.Create(presenterType); ActionInfo actionInfo = presenterInfo.FindAction("TestAction"); DependencyObject source = new DependencyObject(); ActionMessage message = new ActionMessage(); message.Parameters.Add(new Parameter(4.2)); TestPresenter presenter = new TestPresenter(); actionInfo.Execute(presenter, message, source); presenter.WaitHandle.WaitOne(); Assert.IsTrue(presenter.TestActionCalled); }); } } }