public void CloseDoesNotExist() { CreateContainerWithRealMessageBus(); var title = Guid.NewGuid().ToString(); var viewModel = Substitute.For<ITitledViewModel>(); viewModel.Title.Returns(title); var view = new FrameworkElement(); view.DataContext = viewModel; var viewTarget = ViewTargets.DefaultView; var viewResult = new ViewResult(view, viewTarget); var viewBuilder = Substitute.For<IViewFactory>(); viewBuilder.Build(Arg.Any<ViewTargets>(), Arg.Any<Object>()) .Returns(viewResult); ComponentContainer.Container.Register(Component.For<IViewFactory>().Instance(viewBuilder)); var window = new Window(); var tabControl = new TabControl(); var viewController = new ViewPlacer(window, tabControl); var newTabItem = new TabItem() { Header = Guid.NewGuid().ToString() }; tabControl.Items.Add(newTabItem); var message = new CloseViewMessage(title); _MessageBus.Publish<CloseViewMessage>(message); Assert.AreEqual(1, tabControl.Items.Count); }
public MainWindow() { InitializeComponent(); ViewPlacer = new ViewPlacer(this, MainTabControl); ComponentContainer.Container.Register(Component.For<IViewPlacer>().Instance(ViewPlacer)); ViewController = ComponentContainer.Container.Resolve<ViewController>(); }
public void ShowView() { CreateContainer(); var title = Guid.NewGuid().ToString(); var viewModel = Substitute.For<ITitledViewModel>(); viewModel.Title.Returns(title); var view = new FrameworkElement(); view.DataContext = viewModel; var viewTarget = ViewTargets.DefaultView; var viewResult = new ViewResult(view, viewTarget); var window = new Window(); var tabControl = new TabControl(); var viewPlacer = new ViewPlacer(window, tabControl); viewPlacer.PlaceView(viewResult); var viewFound = false; foreach (TabItem tabItem in tabControl.Items) { if (tabItem.Header.ToString() == title) { viewFound = true; } } Assert.IsTrue(viewFound); }
public void ShowView_InvalidViewModel() { CreateContainer(); var viewModel = new object(); var view = new FrameworkElement(); view.DataContext = viewModel; var viewTarget = ViewTargets.DefaultView; var viewResult = new ViewResult(view, viewTarget); var window = new Window(); var tabControl = new TabControl(); var viewPlacer = new ViewPlacer(window, tabControl); viewPlacer.PlaceView(viewResult); }
public void ShowView_AdvancedSearch() { CreateContainer(); var title = Guid.NewGuid().ToString(); var viewModel = Substitute.For<IModalViewModel>(); var view = new MockModalView(); view.DataContext = viewModel; var viewTarget = MoviesViewTargets.AdvancedSearch; var viewResult = new ViewResult(view, viewTarget); var window = new Window(); var tabControl = new TabControl(); var viewPlacer = new ViewPlacer(window, tabControl); viewPlacer.PlaceView(viewResult); Assert.IsTrue(view.ShowModalCalled); _MessageBus.Received().Publish<ModalViewClosedMessage>(Arg.Any<ModalViewClosedMessage>()); }