Esempio n. 1
0
        public void CanInitPresenter()
        {
            eventAggregator.AddMapping <MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent());
            WatchListPresentationModel presentationModel = CreatePresenter();

            Assert.AreEqual <IWatchListView>(view, presentationModel.View);
        }
Esempio n. 2
0
        public void PresenterUnsubcribesFromFundAddedEventIfCustomerIDIsSetTwice()
        {
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent  = new MockFundAddedEvent();
            string             customerId = "ALFKI";
            FundOrder          payload    = new FundOrder()
            {
                CustomerId = customerId, TickerSymbol = "MSFT"
            };

            mockEvent.Subscribe(delegate { new FundOrder()
                                           {
                                               CustomerId = customerId, TickerSymbol = "MSFT"
                                           }; }, ThreadOption.UIThread, true, delegate { return(true); });
            mockEventAggregator.AddMapping <FundAddedEvent>(mockEvent);
            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);

            presenter.View = new MockActivityView();


            presenter.CustomerId = "ALFKI";
            presenter.CustomerId = "ALFKI";

            Assert.AreEqual(1, mockEvent.SubscribeCount);
        }
Esempio n. 3
0
        public void PresenterAddsFundOnEvent()
        {
            var view = new MockActivityView();
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();

            mockEventAggregator.AddMapping <FundAddedEvent>(mockEvent);

            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);

            presenter.View = view;
            string customerId = "ALFKI";

            presenter.CustomerId = customerId;
            FundOrder payload = new FundOrder()
            {
                CustomerId = customerId, TickerSymbol = "MSFT"
            };

            mockEvent.Subscribe(delegate { new FundOrder()
                                           {
                                               CustomerId = customerId, TickerSymbol = "MSFT"
                                           }; }, ThreadOption.UIThread, true, delegate { return(true); });
            mockEvent.Publish(payload);
            StringAssert.Contains(view.AddContentArgumentContent, "MSFT");
        }
 public void SetUp()
 {
     view                 = new MockPositionSummaryView();
     ordersController     = new MockOrdersController();
     observablePosition   = new MockObservablePosition();
     this.eventAggregator = new MockEventAggregator();
     eventAggregator.AddMapping <TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
 }
Esempio n. 5
0
        private static IEventAggregator CreateEventAggregator()
        {
            var eventAggregator = new MockEventAggregator();

            eventAggregator.AddMapping <MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent());

            return(eventAggregator);
        }
 public void SetUp()
 {
     view = new MockPositionSummaryView();
     ordersController = new MockOrdersController();
     observablePosition = new MockObservablePosition();
     this.eventAggregator = new MockEventAggregator();
     eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
 }
Esempio n. 7
0
        public void PresenterSubscribesToFundAddedForCorrectCustomer()
        {
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();

            mockEventAggregator.AddMapping <FundAddedEvent>(mockEvent);
            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);

            presenter.View = new MockActivityView();

            string customerId = "ALFKI";

            presenter.CustomerId = customerId;

            FundOrder payload = new FundOrder()
            {
                CustomerId = customerId
            };

            mockEvent.Subscribe(delegate { new FundOrder()
                                           {
                                               CustomerId = customerId
                                           }; }, ThreadOption.UIThread, true, delegate {
                if (customerId == "ALFKI")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });
            mockEvent.Publish(payload);

            Assert.IsTrue(mockEvent.SubscribeArgumentFilter(new FundOrder {
                CustomerId = "ALFKI"
            }));
            Assert.AreEqual(ThreadOption.UIThread, mockEvent.ThreadOption);
            customerId = "FilteredOutCustomer";
            mockEvent.Subscribe(delegate { new FundOrder()
                                           {
                                               CustomerId = customerId
                                           }; }, ThreadOption.UIThread, true, delegate {
                if (customerId == "ALFKI")
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            });
            Assert.IsFalse(mockEvent.SubscribeArgumentFilter(new FundOrder {
                CustomerId = "FilteredOutCustomer"
            }));
        }
        public void CanInitPresenter()
        {
            var historyService = new MockMarketHistoryService();
            var view = new MockTrendLineView();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            TrendLinePresentationModel presentationModel = new TrendLinePresentationModel(view, historyService, eventAggregator);

            Assert.IsNotNull(presentationModel);
        }
Esempio n. 9
0
        public void CanInitPresenter()
        {
            var historyService  = new MockMarketHistoryService();
            var view            = new MockTrendLineView();
            var eventAggregator = new MockEventAggregator();

            eventAggregator.AddMapping <TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            TrendLinePresentationModel presentationModel = new TrendLinePresentationModel(view, historyService, eventAggregator);

            Assert.IsNotNull(presentationModel);
        }
        public void TickerSymbolSelectedPublishesEvent()
        {
            var tickerSymbolSelectedEvent = new MockTickerSymbolSelectedEvent();

            eventAggregator.AddMapping <TickerSymbolSelectedEvent>(tickerSymbolSelectedEvent);
            var presentationModel = CreatePresentationModel();

            presentationModel.CurrentPositionSummaryItem = new PositionSummaryItem("FUND0", 0, 0, 0);

            Assert.IsTrue(tickerSymbolSelectedEvent.PublishCalled);
            Assert.AreEqual("FUND0", tickerSymbolSelectedEvent.PublishArgumentPayload);
        }
Esempio n. 11
0
        public void ShowNewsResolvesPresenterAndCallsSetTickerSymbolOnItAndAddsNamedViewToRegion()
        {
            var presenter = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var controller = new NewsController(CreateRegionManager(), presenter, eventAggregator, new MockNewsReaderPresenter());

            controller.ShowNews("Test");

            Assert.IsNotNull(presenter.SetTickerSymbolArgumentCompanySymbol);
            Assert.AreEqual("Test", presenter.SetTickerSymbolArgumentCompanySymbol);
        }
Esempio n. 12
0
        public void ShouldNotifyReaderWhenCurrentNewsArticleChanges()
        {
            var presenter = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var newsReaderPresenter = new MockNewsReaderPresenter();
            var controller = new NewsController(CreateRegionManager(), presenter, eventAggregator, newsReaderPresenter);

            controller.CurrentNewsArticleChanged(new NewsArticle() { Title = "SomeTitle", Body = "Newsbody" });

            Assert.IsTrue(newsReaderPresenter.SetNewsArticleCalled);
        }
Esempio n. 13
0
        public void ShowNewsResolvesPresenterAndCallsSetTickerSymbolOnItAndAddsNamedViewToRegion()
        {
            var presenter       = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();

            eventAggregator.AddMapping <TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var controller = new NewsController(CreateRegionManager(), presenter, eventAggregator, new MockNewsReaderPresenter());

            controller.ShowNews("Test");

            Assert.IsNotNull(presenter.SetTickerSymbolArgumentCompanySymbol);
            Assert.AreEqual("Test", presenter.SetTickerSymbolArgumentCompanySymbol);
        }
        public void PresenterUnsubcribesFromFundAddedEventIfCustomerIDIsSetTwice()
        {
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();
            mockEventAggregator.AddMapping<FundAddedEvent>(mockEvent);
            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);
            presenter.View = new MockActivityView();

            presenter.CustomerId = "ALFKI";
            presenter.CustomerId = "ALFKI";

            Assert.AreEqual(1, mockEvent.SubscribeCount);
        }
Esempio n. 15
0
        public void ControllerShowNewsViewWhenArticlePresenterReceivesEvent()
        {
            var presenter       = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();

            eventAggregator.AddMapping <TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var newsReaderPresenter = new MockNewsReaderPresenter();

            var controller = new NewsController(new MockRegionManager(), presenter, eventAggregator, newsReaderPresenter);

            controller.ShowNewsReader();

            Assert.IsTrue(newsReaderPresenter.ShowWasCalled);
        }
        public void PresenterSubscribesToFundAddedForCorrectCustomer()
        {
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();
            mockEventAggregator.AddMapping<FundAddedEvent>(mockEvent);
            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);
            presenter.View = new MockActivityView();

            presenter.CustomerId = "ALFKI";

            Assert.IsTrue(mockEvent.SubscribeArgumentFilter(new FundOrder { CustomerId = "ALFKI" }));
            Assert.AreEqual(ThreadOption.UIThread, mockEvent.ThreadOption);
            Assert.IsFalse(mockEvent.SubscribeArgumentFilter(new FundOrder { CustomerId = "FilteredOutCustomer" }));
        }
Esempio n. 17
0
        public void ControllerShowNewsWhenRasingGlobalEvent()
        {
            var presenter = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();
            var tickerSymbolSelectedEvent = new MockTickerSymbolSelectedEvent();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(tickerSymbolSelectedEvent);
            var controller = new NewsController(CreateRegionManager(), presenter, eventAggregator, new MockNewsReaderPresenter());

            controller.Run();

            Assert.IsNotNull(tickerSymbolSelectedEvent.SubscribeArgumentAction);

            tickerSymbolSelectedEvent.SubscribeArgumentAction("TEST_SYMBOL");
            Assert.AreEqual("TEST_SYMBOL", presenter.SetTickerSymbolArgumentCompanySymbol);
        }
Esempio n. 18
0
        public void ControllerShowNewsWhenRasingGlobalEvent()
        {
            var presenter                 = new MockArticlePresentationModel();
            var eventAggregator           = new MockEventAggregator();
            var tickerSymbolSelectedEvent = new MockTickerSymbolSelectedEvent();

            eventAggregator.AddMapping <TickerSymbolSelectedEvent>(tickerSymbolSelectedEvent);
            var controller = new NewsController(CreateRegionManager(), presenter, eventAggregator, new MockNewsReaderPresenter());

            controller.Run();

            Assert.IsNotNull(tickerSymbolSelectedEvent.SubscribeArgumentAction);

            tickerSymbolSelectedEvent.SubscribeArgumentAction("TEST_SYMBOL");
            Assert.AreEqual("TEST_SYMBOL", presenter.SetTickerSymbolArgumentCompanySymbol);
        }
        public void PresenterAddsFundOnEvent()
        {
            var view = new MockActivityView();
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();
            mockEventAggregator.AddMapping<FundAddedEvent>(mockEvent);

            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);
            presenter.View = view;
            string customerId = "ALFKI";
            presenter.CustomerId = customerId;
            FundOrder payload = new FundOrder() { CustomerId = customerId, TickerSymbol = "MSFT" };
            mockEvent.SubscribeArgumentAction(payload);
            StringAssert.Contains(view.AddContentArgumentContent, "MSFT");
        }
Esempio n. 20
0
        public void ShouldNotifyReaderWhenCurrentNewsArticleChanges()
        {
            var presenter       = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();

            eventAggregator.AddMapping <TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var newsReaderPresenter = new MockNewsReaderPresenter();
            var controller          = new NewsController(CreateRegionManager(), presenter, eventAggregator, newsReaderPresenter);

            controller.CurrentNewsArticleChanged(new NewsArticle()
            {
                Title = "SomeTitle", Body = "Newsbody"
            });

            Assert.IsTrue(newsReaderPresenter.SetNewsArticleCalled);
        }
Esempio n. 21
0
        public void PresenterUnsubcribesFromFundAddedEventIfCustomerIDIsSetTwice()
        {
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();

            mockEventAggregator.AddMapping <FundAddedEvent>(mockEvent);
            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);

            presenter.View = new MockActivityView();

            presenter.CustomerId = "ALFKI";
            presenter.CustomerId = "ALFKI";

            Assert.AreEqual(1, mockEvent.SubscribeCount);
        }
Esempio n. 22
0
        public void ControllerShowNewsViewWhenArticlePresenterReceivesEvent()
        {
            var articlePresentationModel = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var newsReaderPresenter = new MockNewsReaderPresenter();
            var regionManager = CreateRegionManager();
            var shellRegion = (MockRegion)regionManager.Regions["SecondaryRegion"];

            var controller = new NewsController(regionManager, articlePresentationModel, eventAggregator, newsReaderPresenter);

            controller.ShowNewsReader();

            Assert.IsTrue(shellRegion.ActivateCalled);
            Assert.AreEqual(newsReaderPresenter.View, shellRegion.ActivateArg);
        }
Esempio n. 23
0
        public void PresenterPublishesFundAddedOnViewAddClick()
        {
            var view = new MockAddFundView();
            var EventAggregator = new MockEventAggregator();
            var mockFundAddedEvent = new MockFundAddedEvent();
            EventAggregator.AddMapping<FundAddedEvent>(mockFundAddedEvent);
            var presenter = new AddFundPresenter(EventAggregator);
            presenter.View = view;
            view.Customer = "99";
            view.Fund = "TestFund";

            view.PublishAddClick();

            Assert.IsTrue(mockFundAddedEvent.PublishCalled);
            Assert.AreEqual("99", mockFundAddedEvent.PublishArgumentPayload.CustomerId);
            Assert.AreEqual("TestFund", mockFundAddedEvent.PublishArgumentPayload.TickerSymbol);
        }
        public void ShouldUpdateModelWithDataFromServiceOnTickerSymbolSelected()
        {
            var historyService = new MockMarketHistoryService();
            var eventAggregator = new MockEventAggregator();
            var tickerSymbolSelected = new MockTickerSymbolSelectedEvent();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(tickerSymbolSelected);
            TrendLinePresentationModel presentationModel = new TrendLinePresentationModel(new MockTrendLineView(), historyService, eventAggregator);

            tickerSymbolSelected.SubscribeArgumentAction("MyTickerSymbol");
            
            Assert.IsTrue(historyService.GetPriceHistoryCalled);
            Assert.AreEqual("MyTickerSymbol", historyService.GetPriceHistoryArgument);
            Assert.IsNotNull(presentationModel.HistoryCollection);
            Assert.AreEqual(historyService.Data.Count, presentationModel.HistoryCollection.Count);
            Assert.AreEqual(historyService.Data[0], presentationModel.HistoryCollection[0]);
            Assert.AreEqual("MyTickerSymbol", presentationModel.TickerSymbol);
        }
Esempio n. 25
0
        public void ControllerShowNewsViewWhenArticlePresenterReceivesEvent()
        {
            var articlePresentationModel = new MockArticlePresentationModel();
            var eventAggregator          = new MockEventAggregator();

            eventAggregator.AddMapping <TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var newsReaderPresenter = new MockNewsReaderPresenter();
            var regionManager       = CreateRegionManager();
            var shellRegion         = (MockRegion)regionManager.Regions["SecondaryRegion"];

            var controller = new NewsController(regionManager, articlePresentationModel, eventAggregator, newsReaderPresenter);

            controller.ShowNewsReader();

            Assert.IsTrue(shellRegion.ActivateCalled);
            Assert.AreEqual(newsReaderPresenter.View, shellRegion.ActivateArg);
        }
Esempio n. 26
0
        public void ShouldUpdateModelWithDataFromServiceOnTickerSymbolSelected()
        {
            var historyService       = new MockMarketHistoryService();
            var eventAggregator      = new MockEventAggregator();
            var tickerSymbolSelected = new MockTickerSymbolSelectedEvent();

            eventAggregator.AddMapping <TickerSymbolSelectedEvent>(tickerSymbolSelected);
            TrendLinePresentationModel presentationModel = new TrendLinePresentationModel(new MockTrendLineView(), historyService, eventAggregator);

            tickerSymbolSelected.SubscribeArgumentAction("MyTickerSymbol");

            Assert.IsTrue(historyService.GetPriceHistoryCalled);
            Assert.AreEqual("MyTickerSymbol", historyService.GetPriceHistoryArgument);
            Assert.IsNotNull(presentationModel.HistoryCollection);
            Assert.AreEqual(historyService.Data.Count, presentationModel.HistoryCollection.Count);
            Assert.AreEqual(historyService.Data[0], presentationModel.HistoryCollection[0]);
            Assert.AreEqual("MyTickerSymbol", presentationModel.TickerSymbol);
        }
        public void PresenterUnsubcribesFromFundAddedEventIfCustomerIDIsSetTwice()
        {
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();
            string customerId = "ALFKI";
            FundOrder payload = new FundOrder() { CustomerId = customerId, TickerSymbol = "MSFT" };
            mockEvent.Subscribe(delegate { new FundOrder() { CustomerId = customerId, TickerSymbol = "MSFT" }; }, ThreadOption.UIThread, true, delegate { return true; });
            mockEventAggregator.AddMapping<FundAddedEvent>(mockEvent);
            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);
            presenter.View = new MockActivityView();


            presenter.CustomerId = "ALFKI";
            presenter.CustomerId = "ALFKI";

            Assert.AreEqual(1, mockEvent.SubscribeCount);
        }
Esempio n. 28
0
        public void PresenterPublishesFundAddedOnViewAddClick()
        {
            var view               = new MockAddFundView();
            var EventAggregator    = new MockEventAggregator();
            var mockFundAddedEvent = new MockFundAddedEvent();

            EventAggregator.AddMapping <FundAddedEvent>(mockFundAddedEvent);
            var presenter = new AddFundPresenter(EventAggregator);

            presenter.View = view;
            view.Customer  = "99";
            view.Fund      = "TestFund";

            view.PublishAddClick();

            Assert.IsTrue(mockFundAddedEvent.PublishCalled);
            Assert.AreEqual("99", mockFundAddedEvent.PublishArgumentPayload.CustomerId);
            Assert.AreEqual("TestFund", mockFundAddedEvent.PublishArgumentPayload.TickerSymbol);
        }
Esempio n. 29
0
        public void PresenterSubscribesToFundAddedForCorrectCustomer()
        {
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();

            mockEventAggregator.AddMapping <FundAddedEvent>(mockEvent);
            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);

            presenter.View = new MockActivityView();

            presenter.CustomerId = "ALFKI";

            Assert.IsTrue(mockEvent.SubscribeArgumentFilter(new FundOrder {
                CustomerId = "ALFKI"
            }));
            Assert.AreEqual(ThreadOption.UIThread, mockEvent.ThreadOption);
            Assert.IsFalse(mockEvent.SubscribeArgumentFilter(new FundOrder {
                CustomerId = "FilteredOutCustomer"
            }));
        }
        public void PresenterSubscribesToFundAddedForCorrectCustomer()
        {
            var mockEventAggregator = new MockEventAggregator();

            MockFundAddedEvent mockEvent = new MockFundAddedEvent();
            mockEventAggregator.AddMapping<FundAddedEvent>(mockEvent);
            ActivityPresenter presenter = new ActivityPresenter(mockEventAggregator);
            presenter.View = new MockActivityView();

            string customerId = "ALFKI";
            presenter.CustomerId = customerId;

            FundOrder payload = new FundOrder() { CustomerId = customerId };
            mockEvent.Subscribe(delegate { new FundOrder() { CustomerId = customerId }; }, ThreadOption.UIThread, true, delegate{
                if (customerId == "ALFKI"){
                    return true;
                }
                else{
                    return false;
                }
                                                                                                                        });
            mockEvent.Publish(payload);

            Assert.IsTrue(mockEvent.SubscribeArgumentFilter(new FundOrder { CustomerId = "ALFKI" }));
            Assert.AreEqual(ThreadOption.UIThread, mockEvent.ThreadOption);
            customerId = "FilteredOutCustomer";
            mockEvent.Subscribe(delegate { new FundOrder() { CustomerId = customerId }; }, ThreadOption.UIThread, true, delegate {
                if (customerId == "ALFKI")
                {
                    return true;
                }
                else {
                    return false;
                }
            });
            Assert.IsFalse(mockEvent.SubscribeArgumentFilter(new FundOrder { CustomerId = "FilteredOutCustomer" }));
        }
Esempio n. 31
0
        private static IEventAggregator CreateEventAggregator()
        {
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent());

            return eventAggregator;
        }
        public void IfOutlookBarMetadataIsSetSelectingViewInOutlookBarControlPublishOutlookBarEventWithCorrectPayload()
        {
            var control = new OutlookBarControl();
            DependencyObject model = new DependencyObject();
            MockEventAggregator eventAggregator = new MockEventAggregator();
            MockOutlookBarEvent outlookBarEvent = new MockOutlookBarEvent();
            eventAggregator.AddMapping<OutlookBarEvent>(outlookBarEvent);
            IRegionAdapter adapter = new OutlookBarControlRegionAdapter(eventAggregator);

            var region = adapter.Initialize(control);
            OutlookBarControl.SetOutlookBarMetadata(model, new OutlookBarMetadata { Payload = "MyPayload" });
            region.Add(model);

            Assert.IsFalse(outlookBarEvent.PublishCalled);
            Assert.IsNull(outlookBarEvent.PublishArgumentPayload);
            control.SelectedItem = model;

            Assert.IsTrue(outlookBarEvent.PublishCalled);
            Assert.IsNotNull(outlookBarEvent.PublishArgumentPayload);
            Assert.AreEqual("MyPayload", outlookBarEvent.PublishArgumentPayload);
        }
        public void CanInitPresentationModel()
        {
            eventAggregator.AddMapping <MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent());

            PositionSummaryPresentationModel presentationModel = CreatePresentationModel();

            Assert.AreEqual(view, presentationModel.View);
        }
Esempio n. 34
0
        public void ControllerShowNewsViewWhenArticlePresenterReceivesEvent()
        {
            var presenter = new MockArticlePresentationModel();
            var eventAggregator = new MockEventAggregator();
            eventAggregator.AddMapping<TickerSymbolSelectedEvent>(new MockTickerSymbolSelectedEvent());
            var newsReaderPresenter = new MockNewsReaderPresenter();

            var controller = new NewsController(new MockRegionManager(), presenter, eventAggregator, newsReaderPresenter);

            controller.ShowNewsReader();

            Assert.IsTrue(newsReaderPresenter.ShowWasCalled);
        }
        public void SelectingViewInOutlookBarControlPublishOutlookBarEvent()
        {
            var control = new OutlookBarControl();
            DependencyObject model = new DependencyObject();
            MockEventAggregator eventAggregator = new MockEventAggregator();
            MockOutlookBarEvent outlookBarEvent = new MockOutlookBarEvent();
            eventAggregator.AddMapping<OutlookBarEvent>(outlookBarEvent);
            IRegionAdapter adapter = new OutlookBarControlRegionAdapter(eventAggregator);

            var region = adapter.Initialize(control);
            region.Add(model);

            Assert.IsFalse(outlookBarEvent.PublishCalled);
            control.SelectedItem = model;

            Assert.IsTrue(outlookBarEvent.PublishCalled);
            Assert.IsNull(outlookBarEvent.PublishArgumentPayload);
        }