コード例 #1
0
ファイル: ViewSelectorTest.cs プロジェクト: mparsin/Elements
        public void WhenCalledConvert_RegistersSharedView()
        {
            const string viewTag = "testView";
            //Arrange
            var converter = new ViewSelector();

            ViewSelector.ResetComposedConverter();

            var view = new UserControl();
            converter.Views = new[] { new Lazy<UserControl, IExportAsViewMetadata>(() => view, new ExportAsViewAttribute(viewTag)), };

            var mockRouter = Mock.Create<IViewModelRouter>();
            const string viewModelTag = "testViewModel";

            Mock.Arrange(() => mockRouter.GetViewTagsForViewModel(viewModelTag)).Returns(new[] { viewTag });

            var mockVM = Mock.Create<TestNotificationViewModel>();

            converter.Router = new Lazy<IViewModelRouter>(() => mockRouter);

            // Act
            var registeredView = (UserControl)converter.Convert(mockVM, new TypeDelegator(typeof(object)), null, null);

            // Assert
            Assert.IsTrue(converter.IsRegistered(mockVM));
            Assert.AreSame(mockVM, registeredView.DataContext);
        }
コード例 #2
0
ファイル: ViewSelectorTest.cs プロジェクト: mparsin/Elements
        public void WhenCalledConvertBack_RaiseNotImplementedException()
        {
            var converter = new ViewSelector();

            converter.ConvertBack(new object(), new TypeDelegator(typeof(object)), new object(), null);
        }