public async Task ShouldRegisterObservableHandlerToNewlyAssignedNestedViewModel()
        {
            var vm = new InteractionAncestorViewModel()
            {
                InteractionViewModel = new InteractionBindViewModel()
            };
            var view = new InteractionAncestorView {
                ViewModel = vm
            };

            var disposable = view.BindInteraction(
                vm,
                vm => vm.InteractionViewModel.Interaction1,
                input =>
            {
                input.SetOutput(true);
                return(Observable.Return(Unit.Default));
            });

            vm.InteractionViewModel = new InteractionBindViewModel();

            bool isDeletionConfirmed = await vm.InteractionViewModel.Interaction1.Handle("123");

            isDeletionConfirmed.Should().BeTrue();
        }
        public async Task NestedInteractionShouldReceiveOutputFromTaskHandler()
        {
            var vm   = new InteractionAncestorViewModel();
            var view = new InteractionAncestorView {
                ViewModel = vm
            };

            var disposable = view.BindInteraction(
                vm,
                vm => vm.InteractionViewModel.Interaction1,
                input =>
            {
                input.SetOutput(true);
                return(Task.CompletedTask);
            });

            bool isDeletionConfirmed = await vm.InteractionViewModel.Interaction1.Handle("123");

            isDeletionConfirmed.Should().BeTrue();
        }
Exemplo n.º 3
0
        public async Task NestedInteractionShouldReceiveOutputFromObservableHandler()
        {
            var vm   = new InteractionAncestorViewModel();
            var view = new InteractionAncestorView {
                ViewModel = vm
            };

            var disp = view.BindInteraction(
                vm,
                vm => vm.InteractionViewModel.Interaction1,
                input =>
            {
                input.SetOutput(true);
                return(Observable.Return(Unit.Default));
            });

            bool isDeletionConfirmed = await vm.InteractionViewModel.Interaction1.Handle("123");

            isDeletionConfirmed.Should().BeTrue();
        }
        public void ShouldUnregisterObservableHandlerFromOverwrittenNestedViewModel()
        {
            var firstInteractionVm = new InteractionBindViewModel();
            var vm   = new InteractionAncestorViewModel();
            var view = new InteractionAncestorView {
                ViewModel = vm
            };

            var disposable = view.BindInteraction(
                vm,
                vm => vm.InteractionViewModel.Interaction1,
                input =>
            {
                input.SetOutput(true);
                return(Observable.Return(Unit.Default));
            });

            view.ViewModel.InteractionViewModel = new InteractionBindViewModel();

            _ = Assert.ThrowsAsync <UnhandledInteractionException <string, bool> >(() => firstInteractionVm.Interaction1.Handle("123").ToTask());
        }