public void CanInitPresenter() { eventAggregator.AddMapping <MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent()); WatchListPresentationModel presentationModel = CreatePresenter(); Assert.AreEqual <IWatchListView>(view, presentationModel.View); }
public void PresentationModelShouldHaveHeaderInfoSet() { eventAggregator.AddMapping <MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent()); WatchListPresentationModel presentationModel = CreatePresenter(); Assert.AreEqual("WATCH LIST", view.Model.HeaderInfo); }
public void SetModel(WatchListPresentationModel model) { this.DataContext = model; // Because in Silverlight you cannot bind to a RelativeSource, we are using Resources with an observable value, // in order to be able to bind to the Buy and Sell commands. // The resources are declared in the XAML, because Silverlight has StaticResource markup only, so these // resources should be available when the control is initializing, even though the Value is yet not set. Binding binding = new Binding("RemoveWatchCommand"); binding.Source = this.DataContext; ((ObservableCommand)this.Resources["RemoveWatchCommand"]).SetBinding(ObservableCommand.ValueProperty, binding); }
public void ClickingOnTheRemoveMenuItemCallsTheRemoveSelectedItemMethod() { eventAggregator.AddMapping <MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent()); watchListService.MockWatchList.Add("TEST"); WatchListPresentationModel presentationModel = CreatePresenter(); Assert.AreEqual(1, watchListService.MockWatchList.Count); presentationModel.RemoveWatchCommand.Execute("TEST"); Assert.AreEqual(0, watchListService.MockWatchList.Count); }
public void ShouldPublishTickerSymbolSelectedOnSelectionChanged() { var tickerSymbolSelectedEvent = new MockTickerSymbolSelectedEvent(); eventAggregator.AddMapping <TickerSymbolSelectedEvent>(tickerSymbolSelectedEvent); eventAggregator.AddMapping <MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent()); WatchListPresentationModel presentationModel = CreatePresenter(); presentationModel.CurrentWatchItem = new WatchItem("MyTickerSymbol", 10m); Assert.IsTrue(tickerSymbolSelectedEvent.PublishCalled); Assert.AreEqual("MyTickerSymbol", tickerSymbolSelectedEvent.PublishArg); }
public void IfPriceIsNotAvailableForSymbolSetsNullCurrentPriceInView() { eventAggregator.AddMapping <MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent()); watchListService.MockWatchList.Add("NONEXISTING"); marketFeedService.MockSymbolExists = false; WatchListPresentationModel presentationModel = CreatePresenter(); WatchItem watchItem = view.Model.WatchListItems[0]; Assert.AreEqual <string>("NONEXISTING", watchItem.TickerSymbol); Assert.IsNull(watchItem.CurrentPrice); }
public void PresenterObservesWatchListAndUpdatesView() { eventAggregator.AddMapping <MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent()); watchListService.MockWatchList.Add("TESTFUND0"); WatchListPresentationModel presentationModel = CreatePresenter(); Assert.AreEqual(1, view.Model.WatchListItems.Count()); watchListService.MockWatchList.Add("TESTFUND1"); Assert.AreEqual(2, view.Model.WatchListItems.Count()); Assert.AreEqual <string>("TESTFUND1", view.Model.WatchListItems[1].TickerSymbol); }
public void CanGetItemsFromWatchListServiceAndPutInView() { eventAggregator.AddMapping <MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent()); watchListService.MockWatchList.Add("TESTFUND0"); watchListService.MockWatchList.Add("TESTFUND1"); WatchListPresentationModel presentationModel = CreatePresenter(); Assert.IsNotNull(view.Model); Assert.IsNotNull(view.Model.WatchListItems); Assert.AreEqual(2, view.Model.WatchListItems.Count); Assert.AreEqual <string>("TESTFUND0", view.Model.WatchListItems[0].TickerSymbol); Assert.AreEqual <string>("TESTFUND1", view.Model.WatchListItems[1].TickerSymbol); }
public void ViewGetsCurrentPriceForSymbolRetrievedFromMarketFeedService() { eventAggregator.AddMapping <MarketPricesUpdatedEvent>(new MockMarketPricesUpdatedEvent()); watchListService.MockWatchList.Add("TESTFUND0"); marketFeedService.SetPrice("TESTFUND0", 15.5m); WatchListPresentationModel presentationModel = CreatePresenter(); WatchItem watchItem = view.Model.WatchListItems[0]; Assert.AreEqual <string>("TESTFUND0", watchItem.TickerSymbol); Assert.IsNotNull(watchItem.CurrentPrice); Assert.AreEqual <decimal>(15.5m, watchItem.CurrentPrice.Value); }
public void PresenterObservesMarketFeedAndUpdatesView() { var marketPricesUpdatedEvent = new MockMarketPricesUpdatedEvent(); eventAggregator.AddMapping <MarketPricesUpdatedEvent>(marketPricesUpdatedEvent); marketFeedService.feedData.Add("TESTFUND0", 15.5m); watchListService.MockWatchList.Add("TESTFUND0"); WatchListPresentationModel presentationModel = CreatePresenter(); Assert.AreEqual <decimal>(15.5m, view.Model.WatchListItems[0].CurrentPrice.Value); Assert.IsNotNull(marketPricesUpdatedEvent.SubscribeArgumentAction); Assert.AreEqual(ThreadOption.UIThread, marketPricesUpdatedEvent.SubscribeArgumentThreadOption); marketPricesUpdatedEvent.SubscribeArgumentAction(new Dictionary <string, decimal> { { "TESTFUND0", 25.3m } }); Assert.AreEqual <decimal>(25.3m, view.Model.WatchListItems[0].CurrentPrice.Value); }
public void SetModel(WatchListPresentationModel model) { this.Model = model; }
public void SetModel(WatchListPresentationModel model) { this.DataContext = model; }