Exemplo n.º 1
0
        public void CreateWithViewTarget()
        {
            var viewTarget = ViewTargets.Detail;

            var message = new ShowViewMessage(viewTarget);

            Assert.AreEqual(viewTarget, message.ViewTarget);
            Assert.IsNull(message.LoadArgs);
        }
Exemplo n.º 2
0
        public void Create()
        {
            var viewTarget = ViewTargets.Detail;
            var loadArgs = new Object();

            var message = new ShowViewMessage(viewTarget, loadArgs);

            Assert.AreEqual(viewTarget, message.ViewTarget);
            Assert.AreSame(loadArgs, message.LoadArgs);
        }
Exemplo n.º 3
0
        private void HandleShowView(ShowViewMessage args)
        {
            var viewFactory = ComponentContainer.Container.Resolve<IViewFactory>();
            var viewResult = viewFactory.Build(args.ViewTarget, args.LoadArgs);

            var exists = false;
            foreach (TabItem tabItem in _MainTabControl.Items)
            {
                if (tabItem.Header.ToString() == viewResult.Title)
                {
                    exists = true;
                    break;
                }
            }

            if (!exists)
            {
                var newTabItem = new TabItem() { Header = viewResult.Title, Content = viewResult.View };
                _MainTabControl.Items.Add(newTabItem);

                newTabItem.Focus();
            }
        }
Exemplo n.º 4
0
        public void SelectMovie(Object movie)
        {
            var message = new ShowViewMessage(ViewTargets.Detail, movie);

            MessageBus.Publish<ShowViewMessage>(message);
        }
Exemplo n.º 5
0
        public void NewMovie()
        {
            var message = new ShowViewMessage(ViewTargets.Detail, new Movie());

            MessageBus.Publish<ShowViewMessage>(message);
        }
Exemplo n.º 6
0
        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);
        }