Пример #1
0
        public async Task Test_ResumeAsync_Resumes_Stored_ViewModel_State()
        {
            Resolver.Register(() => new TestReActivatableViewModel(), typeof(TestReActivatableViewModel));
            Navigator = new Navigator();
            Router    = new Router(Navigator);
            var routerParams = new RouterBuilder()
                               .When <TestReActivatableViewModel>(r => r.Navigate())
                               .Build();
            var viewModelState = new TestState();
            var savedState     = new RouterState()
            {
                Actions = new[]
                {
                    new Router.StoredRouterAction()
                    {
                        Action         = RouterActions.ShowViewModel(typeof(TestReActivatableViewModel), new TestParams()),
                        ViewModelState = viewModelState
                    },
                }
            };

            await Router.InitAsync(routerParams);

            await Router.ResumeAsync(savedState);

            Assert.Collection(Navigator.TransitionStack,
                              t =>
            {
                t.ViewModel.Should().BeAssignableTo <TestReActivatableViewModel>();
                t.ViewModel.As <TestReActivatableViewModel>().State.Should().Be(viewModelState);
            });
        }
Пример #2
0
 public async Task Test_ShowAsync_Throws_If_Router_Is_Not_Initialized()
 {
     await Assert.ThrowsAsync <InvalidOperationException>(async() =>
     {
         await Router.DispatchAsync(RouterActions.ShowViewModel(typeof(TestViewModel), new TestParams()));
     });
 }