public void CloseExists()
        {
            CreateContainer();
            var view = new FrameworkElement();
            var title = Guid.NewGuid().ToString();

            var viewResult = new ViewResult(view, title);
            var viewBuilder = MockRepository.GenerateStub<IViewFactory>();
            viewBuilder.Stub(vb => vb.Build(Arg<ViewTargets>.Is.Anything, Arg<Object>.Is.Anything))
                .Return(viewResult);
            ComponentContainer.Container.Kernel.AddComponentInstance<IViewFactory>(viewBuilder);

            var tabControl = new TabControl();
            var viewController = new ViewController(tabControl);
            var newTabItem = new TabItem() { Header = title };
            tabControl.Items.Add(newTabItem);

            var message = new CloseViewMessage(title);
            _MessageBus.Publish<CloseViewMessage>(message);

            Assert.AreEqual(0, tabControl.Items.Count);
        }
Example #2
0
        public Window1()
        {
            InitializeComponent();

            _ViewController = new ViewController(MainTabControl);
        }
        public void ShowView()
        {
            CreateContainer();
            var view = new FrameworkElement();
            var title = Guid.NewGuid().ToString();

            var viewResult = new ViewResult(view, title);
            var viewBuilder = MockRepository.GenerateStub<IViewFactory>();
            viewBuilder.Stub(vb => vb.Build(Arg<ViewTargets>.Is.Anything, Arg<Object>.Is.Anything))
                .Return(viewResult);
            ComponentContainer.Container.Kernel.AddComponentInstance<IViewFactory>(viewBuilder);

            var tabControl = new TabControl();
            var viewController = new ViewController(tabControl);

            var message = new ShowViewMessage(ViewTargets.Detail);
            _MessageBus.Publish<ShowViewMessage>(message);

            var viewFound = false;
            foreach (TabItem tabItem in tabControl.Items)
            {
                if (tabItem.Header.ToString() == title)
                {
                    viewFound = true;
                }
            }

            Assert.IsTrue(viewFound);
        }