public void MarketUpdatesPresenterPositionUpdatesButCollectionDoesNot()
        {
            var marketPricesUpdatedEvent = new MockMarketPricesUpdatedEvent();

            eventAggregator.AddMapping <MarketPricesUpdatedEvent>(marketPricesUpdatedEvent);

            marketFeedService.SetPrice("FUND1", 20.00m);
            accountPositionService.AddPosition("FUND1", 15.00m, 100);

            var presentationModel = CreatePresentationModel();

            bool presentationModelCollectionUpdated = false;

            presentationModel.PositionSummaryItems.CollectionChanged += delegate
            {
                presentationModelCollectionUpdated = true;
            };

            bool presentationModelItemUpdated = false;

            presentationModel.PositionSummaryItems.First(p => p.TickerSymbol == "FUND1").PropertyChanged += delegate
            {
                presentationModelItemUpdated = true;
            };

            marketPricesUpdatedEvent.SubscribeArgumentAction(new Dictionary <string, decimal> {
                { "FUND1", 50m }
            });

            Assert.IsFalse(presentationModelCollectionUpdated);
            Assert.IsTrue(presentationModelItemUpdated);
        }
Beispiel #2
0
        public void PresenterUpdatesDataWithMarketUpdates()
        {
            var marketPricesUpdatedEvent = new MockMarketPricesUpdatedEvent();
            eventAggregator.AddMapping<MarketPricesUpdatedEvent>(marketPricesUpdatedEvent);

            marketFeedService.SetPrice("FUND0", 30.00m);
            accountPositionService.AddPosition("FUND0", 25.00m, 1000);
            marketFeedService.SetPrice("FUND1", 20.00m);
            accountPositionService.AddPosition("FUND1", 15.00m, 100);
            var presentationModel = CreatePresentationModel();

            var updatedPriceList = new Dictionary<string, decimal> { { "FUND0", 50.00m } };

            Assert.IsNotNull(marketPricesUpdatedEvent.SubscribeArgumentAction);
            Assert.AreEqual(ThreadOption.UIThread, marketPricesUpdatedEvent.SubscribeArgumentThreadOption);


            marketPricesUpdatedEvent.SubscribeArgumentAction(updatedPriceList);

            Assert.AreEqual<decimal>(50.00m, presentationModel.PositionSummaryItems.First(x => x.TickerSymbol == "FUND0").CurrentPrice);
        }
        public void PresenterUpdatesDataWithMarketUpdates()
        {
            var marketPricesUpdatedEvent = new MockMarketPricesUpdatedEvent();
            eventAggregator.AddMapping<MarketPricesUpdatedEvent>(marketPricesUpdatedEvent);

            marketFeedService.SetPrice("FUND0", 30.00m);
            accountPositionService.AddPosition("FUND0", 25.00m, 1000);
            marketFeedService.SetPrice("FUND1", 20.00m);
            accountPositionService.AddPosition("FUND1", 15.00m, 100);
            var presentationModel = CreatePresentationModel();

            var updatedPriceList = new Dictionary<string, decimal> { { "FUND0", 50.00m } };

            Assert.IsNotNull(marketPricesUpdatedEvent.SubscribeArgumentAction);
            Assert.AreEqual(ThreadOption.UIThread, marketPricesUpdatedEvent.SubscribeArgumentThreadOption);


            marketPricesUpdatedEvent.SubscribeArgumentAction(updatedPriceList);

            Assert.AreEqual<decimal>(50.00m, presentationModel.PositionSummaryItems.First(x => x.TickerSymbol == "FUND0").CurrentPrice);
        }
        public void MarketUpdatesPresenterPositionUpdatesButCollectionDoesNot()
        {
            var marketPricesUpdatedEvent = new MockMarketPricesUpdatedEvent();
            eventAggregator.AddMapping<MarketPricesUpdatedEvent>(marketPricesUpdatedEvent);

            marketFeedService.SetPrice("FUND1", 20.00m);
            accountPositionService.AddPosition("FUND1", 15.00m, 100);

            var presentationModel = CreatePresentationModel();

            bool presentationModelCollectionUpdated = false;
            presentationModel.PositionSummaryItems.CollectionChanged += delegate
              {
                  presentationModelCollectionUpdated = true;
              };

            bool presentationModelItemUpdated = false;
            presentationModel.PositionSummaryItems.First(p => p.TickerSymbol == "FUND1").PropertyChanged += delegate
               {
                   presentationModelItemUpdated = true;
               };

            marketPricesUpdatedEvent.SubscribeArgumentAction(new Dictionary<string, decimal> { { "FUND1", 50m } });

            Assert.IsFalse(presentationModelCollectionUpdated);
            Assert.IsTrue(presentationModelItemUpdated);
        }