コード例 #1
0
        public void PresentShouldInvokeCallbackOnClear()
        {
            var vm = GetViewModel <NavigableViewModelMock>();
            IOperationCallback operationCallback = null;

            ApplicationSettings.Platform      = new PlatformInfo(PlatformType.WPF, new Version(0, 0));
            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);
            IAsyncOperation <bool?> task = presenter.TryShowAsync(vm, DataContext.Empty, null);

            task.ShouldNotBeNull();
            task.IsCompleted.ShouldBeFalse();
            viewModel.Clear();
            task.IsCompleted.ShouldBeTrue();
            task.Result.Result.ShouldEqual(true);
            operationCallback.ShouldNotBeNull();
        }
コード例 #2
0
        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();
            IDynamicViewModelPresenter presenter = new DynamicMultiViewModelPresenter(viewModel,
                                                                                      OperationCallbackManager, (model, context, arg3) => true);
            IAsyncOperation <bool?> 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();
        }