public void ShouldActivateViewOnWatchItemAdded()
        {
            try
            {
                var mockRegionContentRegistry = new MockRegionViewRegistry();
                ServiceLocator.SetLocatorProvider(
                    () => new MockServiceLocator(
                              () => mockRegionContentRegistry));
                var watchListView = new MockWatchListView();
                var regionManager = new MockRegionManager();
                var region = new MockRegion();
                region.Add(watchListView);
                regionManager.Regions.Add("MainRegion", region);
                var presentationModel = new MockWatchListPresentationModel { View = watchListView };
                WatchListController controller =
                    new WatchListController(regionManager, presentationModel);

                controller.Run();

                presentationModel.WatchListItems.Add(new WatchItem("MySymbol", 10m));

                Assert.IsTrue(region.ActivateCalled);
                Assert.AreSame(watchListView, region.ActivateArg);
            }
            finally
            {
                ServiceLocator.SetLocatorProvider(() => null);
            }
        }
Example #2
0
        public void ShouldRunControllerOnInitialization()
        {
            var regionManager = new MockRegionManager();
            var container = new MockUnityResolver();
            IModule module = new WatchModule(container, regionManager);
            var contentRegistry = new MockRegionViewRegistry();
            ServiceLocator.SetLocatorProvider(
               () => new MockServiceLocator(
                       () => contentRegistry));
            container.Bag.Add(typeof(IAddWatchPresenter), new MockAddWatchPresenter());
            container.Bag.Add(typeof(IWatchListPresentationModel), new MockWatchListPresentationModel());
            var controller = new MockWatchListController();
            container.Bag.Add(typeof(IWatchListController), controller);
            regionManager.Regions.Add("MainToolBarRegion", new MockRegion());

            module.Initialize();

            Assert.IsTrue(controller.RunCalled);
        }
        public void InitAddsAddWatchControlViewToToolbarRegion()
        {
            var toolbarRegion = new MockRegion();
            var collapsibleRegion = new MockRegion();
            var regionManager = new MockRegionManager();
            var container = new MockUnityResolver();
            container.Bag.Add(typeof(IAddWatchPresenter), new MockAddWatchPresenter());
            container.Bag.Add(typeof(IWatchListPresentationModel), new MockWatchListPresentationModel());
            IModule module = new WatchModule(container, regionManager);
            regionManager.Regions.Add("WatchRegion", collapsibleRegion);
            regionManager.Regions.Add("MainToolbarRegion", toolbarRegion);

            Assert.AreEqual(0, toolbarRegion.AddedViews.Count);
            Assert.AreEqual(0, collapsibleRegion.AddedViews.Count);

            module.Initialize();

            Assert.AreEqual(1, toolbarRegion.AddedViews.Count);
            Assert.AreEqual(1, collapsibleRegion.AddedViews.Count);
        }
Example #4
0
        public void InitAddsAddWatchControlViewToToolbarRegion()
        {
            var regionManager = new MockRegionManager();
            var container = new MockUnityResolver();
            IModule module = new WatchModule(container, regionManager);
            var contentRegistry = new MockRegionViewRegistry();
            ServiceLocator.SetLocatorProvider(
               () => new MockServiceLocator(
                       () => contentRegistry));

            container.Bag.Add(typeof(IAddWatchPresenter), new MockAddWatchPresenter());
            container.Bag.Add(typeof(IWatchListPresentationModel), new MockWatchListPresentationModel());
            container.Bag.Add(typeof(IWatchListController), new MockWatchListController());
            regionManager.Regions.Add("MainToolBarRegion", new MockRegion());

            Assert.AreEqual(0, contentRegistry.RegisterViewWithRegionRegionNameArg.Count);

            module.Initialize();

            Assert.AreEqual(1, contentRegistry.RegisterViewWithRegionRegionNameArg.Count);
            Assert.IsTrue(contentRegistry.RegisterViewWithRegionRegionNameArg.Contains("MainToolBarRegion"));
        }