Ejemplo n.º 1
0
        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);
            }
        }
        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);
        }