public virtual void ShowCallbackShouldBeInvokedAfterWindowClosedTrueResult() { var view = new DialogViewMock(); var vm = GetViewModel <NavigableViewModelMock>(); ViewManager.GetViewDelegate = (model, s) => view; WindowViewMediatorBase <TView> windowMediator = Create(vm); var mockCallback = new OperationCallbackMock(); bool isRegistered = false; IOperationResult operationResult = null; OperationCallbackManager.Register = (type, o, arg3, arg4) => { type.ShouldEqual(OperationType.WindowNavigation); o.ShouldEqual(vm); arg3.ShouldEqual(mockCallback); isRegistered = true; }; OperationCallbackManager.SetResult = (o, result) => { o.ShouldEqual(vm); (result.OperationContext is INavigationContext).ShouldBeTrue(); operationResult = result; }; windowMediator.ShowAsync(mockCallback, DataContext.Empty); isRegistered.ShouldBeTrue(); vm.OperationResult = true; windowMediator.CloseAsync(null).Result.ShouldBeTrue(); operationResult.ShouldNotBeNull(); operationResult.Result.ShouldEqual(true); }
public virtual void ClosingEventFromViewShouldCloseWindow() { var view = new DialogViewMock(); var vm = GetViewModel <NavigableViewModelMock>(); ViewManager.GetViewDelegate = (model, s) => view; WindowViewMediatorBase <TView> windowMediator = Create(vm); IOperationResult operationResult = null; OperationCallbackManager.SetResult = (o, result) => operationResult = result; windowMediator.ShowAsync(null, DataContext.Empty); view.Close(); operationResult.ShouldNotBeNull(); windowMediator.IsOpen.ShouldBeFalse(); }