Пример #1
0
            public void CanNavigateToNewViewWithViewKeyAwareViewModel()
            {
                // Prepare
                var fakeViewModel  = new FakeViewKeyAwareViewModel();
                var navigationInfo = NavigationInfo.CreateSimple("viewKey", fakeViewModel);

                // Act
                var expectedViewInfo = _navigationService.NavigateTo <UserControl>(navigationInfo);

                // Verify
                Assert.IsNotNull(expectedViewInfo.View.DataContext);
                Assert.AreEqual(navigationInfo.ViewKey, ((IViewKeyAware)expectedViewInfo.View.DataContext).ViewKey);
            }
Пример #2
0
            public void CanNavigateAndAttachNewViewWithViewKeyAwareViewModelToParentView()
            {
                // Prepare
                var fakeViewModel        = new FakeViewKeyAwareViewModel();
                var parentNavigationInfo = NavigationInfo.CreateSimple("parentViewKey");
                var childNavigationInfo  = NavigationInfo.CreateComplex("childViewKey", parentNavigationInfo.ViewKey, fakeViewModel);

                _navigationService.NavigateTo <UserControl>(parentNavigationInfo);

                // Act
                var expectedViewInfo = _navigationService.NavigateTo <UserControl>(childNavigationInfo);

                // Verify
                Assert.IsNotNull(expectedViewInfo.View.DataContext);
                Assert.AreEqual(childNavigationInfo.ViewKey, ((IViewKeyAware)expectedViewInfo.View.DataContext).ViewKey);
            }