public void PresentShouldInvokeCallbackOnClear()
        {
            var vm = GetViewModel<NavigableViewModelMock>();
            IOperationCallback operationCallback = null;
            OperationCallbackManager.Register = (type, o, arg3, arg4) =>
            {
                type.ShouldEqual(OperationType.TabNavigation);
                operationCallback = arg3;
            };
            OperationCallbackManager.SetResult = (o, result) =>
            {
                result.Operation.ShouldEqual(OperationType.TabNavigation);
                o.ShouldEqual(vm);
                operationCallback.Invoke(result);
            };

            vm.OperationResult = true;
            MultiViewModel viewModel = GetMultiViewModel();
            IDynamicViewModelPresenter presenter = new DynamicMultiViewModelPresenter(viewModel,
                OperationCallbackManager);
            var task = presenter.TryShowAsync(vm, DataContext.Empty, null);
            task.ShouldNotBeNull();
            task.IsCompleted.ShouldBeFalse();
            viewModel.Clear();
            task.IsCompleted.ShouldBeTrue();
            task.Result.Result.ShouldEqual(true);
            operationCallback.ShouldNotBeNull();
        }
        public void PresentShouldInvokeCallbackOnRemove()
        {
            var vm = GetViewModel<NavigableViewModelMock>();
            IOperationCallback operationCallback = null;
            OperationCallbackManager.Register = (type, o, arg3, arg4) =>
            {
                type.ShouldEqual(OperationType.TabNavigation);
                operationCallback = arg3;
            };
            OperationCallbackManager.SetResult = (o, result) =>
            {
                result.Operation.ShouldEqual(OperationType.TabNavigation);
                o.ShouldEqual(vm);
                operationCallback.Invoke(result);
            };

            vm.OperationResult = true;
            MultiViewModel viewModel = GetMultiViewModel();
            ((SynchronizedNotifiableCollection<IViewModel>)viewModel.ItemsSource).ThreadManager = new ThreadManagerMock { IsUiThread = true };
            IDynamicViewModelPresenter presenter = new DynamicMultiViewModelPresenter(viewModel,
                OperationCallbackManager, (model, context, arg3) => true);
            var task = presenter.TryShowAsync(vm, DataContext.Empty, null);
            task.ShouldNotBeNull();
            task.IsCompleted.ShouldBeFalse();
            viewModel.RemoveViewModelAsync(vm).Result.ShouldBeTrue();
            task.IsCompleted.ShouldBeTrue();
            task.Result.Result.ShouldEqual(true);
            operationCallback.ShouldNotBeNull();
        }
 public void PresenterShouldAddVmToMultiViewModel()
 {
     var vm = GetViewModel<NavigableViewModelMock>();
     MultiViewModel viewModel = GetMultiViewModel();
     IDynamicViewModelPresenter presenter = new DynamicMultiViewModelPresenter(viewModel,
         OperationCallbackManager, (model, context, arg3) => true);
     var task = presenter.TryShowAsync(vm, DataContext.Empty, null);
     task.ShouldNotBeNull();
     task.IsCompleted.ShouldBeFalse();
     viewModel.ItemsSource.Contains(vm).ShouldBeTrue();
 }