public void WhenCalledConvert_RegistersNonSharedView()
        {
            //Arrange
            var converter = new TopLevelViewConverter();

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

            Mock.Arrange(() => mockRouter.GetViewTagsForViewModel(Arg.IsAny<string>())).Returns(new[] { viewTag });
            var view = new UserControl();
            Mock.Arrange(() => mockRouter.GetNonSharedView(Arg.IsAny<string>(), Arg.IsAny<object>())).Returns(view);

            var mockWindow = Mock.Create<ITopLevelWindow>();
            Mock.Arrange(() => mockWindow.GetExportAsViewModelAttribute()).Returns(new ExportAsViewModelAttribute(viewModelTag));
            converter.Router = new Lazy<IViewModelRouter>(() => mockRouter);
            converter.Views = new[] { new Lazy<UserControl, IExportAsViewMetadata>(() => view, new ExportAsViewAttribute(viewTag)), };
            Mock.Arrange(() => TopLevelViewConverter.ComposedConverter).Returns(new TopLevelViewConverter());

            // Act
            converter.Convert(mockWindow, new TypeDelegator(typeof(object)), null, null);

            // Assert
            Assert.IsTrue(converter.IsRegistered(mockWindow));
        }
 public void WhenCalledConvertBack_RaiseNotImplementedException()
 {
     var converter = new TopLevelViewConverter();
     converter.ConvertBack(new object(), new TypeDelegator(typeof (object)), new object(), null);
 }
            public TopLevelViewConverter CreateConverter(string viewTag)
            {
                var router = Mock.Create<IViewModelRouter>();
                Mock.Arrange(() => router.GetViewTagsForViewModel(Arg.IsAny<string>())).Returns(new[] { viewTag });

                var converter = Mock.Create<TopLevelViewConverter>(Constructor.NotMocked, Behavior.CallOriginal);
                converter.Router = new Lazy<IViewModelRouter>(() => router);
                converter.Views = new[] { new Lazy<UserControl, IExportAsViewMetadata>(this.CreateDetailsView, new ExportAsViewAttribute(viewTag)) };

                var composedConverter = new TopLevelViewConverter { Router = converter.Router, Views = converter.Views };

                Mock.Arrange(() => TopLevelViewConverter.ComposedConverter).Returns(composedConverter);

                return converter;
            }