예제 #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);
            }
        }
예제 #2
0
        public void ShouldRegisterWatchListViewOnRegion()
        {
            try
            {
                var mockRegionContentRegistry = new MockRegionViewRegistry();
                ServiceLocator.SetLocatorProvider(
                    () => new MockServiceLocator(
                        () => mockRegionContentRegistry));
                var presentationModel = new MockWatchListPresentationModel();
                var watchListView = new MockWatchListView();
                presentationModel.View = watchListView;
                WatchListController controller = 
                    new WatchListController ( new MockRegionManager(), presentationModel);

                controller.Run();

                Assert.AreEqual(1, mockRegionContentRegistry.RegisteredViews.Count);
                Assert.IsTrue(mockRegionContentRegistry.RegisteredViews.ContainsKey("MainRegion"));
                Assert.AreSame(watchListView, mockRegionContentRegistry.RegisteredViews["MainRegion"]);
            }
            finally
            {
                ServiceLocator.SetLocatorProvider(() => null);
            }
        }