Exemple #1
0
        public void ServiceExposesCommandInstance()
        {
            WatchListService service = new WatchListService(new MockMarketFeedService());

            Assert.AreEqual(0, service.RetrieveWatchList().Count);
            service.AddWatchCommand.Execute("testSymbol");
            Assert.AreEqual(1, service.RetrieveWatchList().Count);
            Assert.AreEqual("TESTSYMBOL", service.RetrieveWatchList()[0]);
        }
Exemple #2
0
        public void SymbolWithTrailingBlankSpacesIsAddedToList()
        {
            WatchListService service = new WatchListService(new MockMarketFeedService());

            service.AddWatchCommand.Execute("FUND0    ");

            Assert.AreEqual(1, service.RetrieveWatchList().Count);
            Assert.AreEqual("FUND0", service.RetrieveWatchList()[0]);
        }
Exemple #3
0
        public void ServiceListensToAddWatchCommand()
        {
            WatchListService service = new WatchListService(new MockMarketFeedService());

            Assert.AreEqual(0, service.RetrieveWatchList().Count);

            service.AddWatchCommand.Execute("Stock999");

            Assert.AreEqual(1, service.RetrieveWatchList().Count);
        }
Exemple #4
0
        public void AddingSameSymbolOneWithTrailingBlankSpacesTwiceOnlyAddsItOnceToTheList()
        {
            WatchListService service = new WatchListService(new MockMarketFeedService());

            service.AddWatchCommand.Execute("FUND0    ");
            service.AddWatchCommand.Execute("FUND0");

            Assert.AreEqual(1, service.RetrieveWatchList().Count);
            Assert.AreEqual("FUND0", service.RetrieveWatchList()[0]);
        }
Exemple #5
0
        public void ServiceListensToAddWatchCommandAndReturnsCommandParamsInList()
        {
            WatchListService service = new WatchListService(new MockMarketFeedService());

            service.AddWatchCommand.Execute("STOCK00");
            service.AddWatchCommand.Execute("STOCK99");

            Assert.AreEqual(2, service.RetrieveWatchList().Count);
            Assert.AreEqual <string>("STOCK00", service.RetrieveWatchList()[0]);
            Assert.AreEqual <string>("STOCK99", service.RetrieveWatchList()[1]);
        }
        public void TickerSymbolGetsConvertedToUppercase()
        {
            WatchListService service = new WatchListService(new MockMarketFeedService());

            service.AddWatchCommand.Execute("StockInMixedCase");

            Assert.AreEqual <string>("StockInMixedCase".ToUpperInvariant(), service.RetrieveWatchList()[0]);
        }
Exemple #7
0
        public void AddingSameSymbolTwiceOnlyAddsItOnceToTheList()
        {
            WatchListService service = new WatchListService(new MockMarketFeedService());

            service.AddWatchCommand.Execute("DUPE");
            service.AddWatchCommand.Execute("DUPE");

            Assert.AreEqual(1, service.RetrieveWatchList().Count);
        }
Exemple #8
0
        public void NullOrEmptyStringIsNotAddedToList()
        {
            WatchListService service = new WatchListService(new MockMarketFeedService());

            service.AddWatchCommand.Execute(null);
            service.AddWatchCommand.Execute(string.Empty);

            Assert.AreEqual(0, service.RetrieveWatchList().Count);
        }
Exemple #9
0
        public void DoesNotAddWatchIfSymbolDoesNotExistInMarketFeed()
        {
            MockMarketFeedService marketFeedService = new MockMarketFeedService();

            marketFeedService.MockSymbolExists = false;

            WatchListService service = new WatchListService(marketFeedService);

            service.AddWatchCommand.Execute("INEXISTENT");

            Assert.AreEqual(0, service.RetrieveWatchList().Count);
            Assert.AreEqual <string>("INEXISTENT", marketFeedService.SymbolExistsArgumentTickerSymbol);
        }
Exemple #10
0
        public void GetWatchListShouldReturnObservableCollection()
        {
            WatchListService service = new WatchListService(new MockMarketFeedService());

            service.AddWatchCommand.Execute("Stock000");
            ObservableCollection <string> watchList = service.RetrieveWatchList();

            bool collectionChanged = false;

            watchList.CollectionChanged += delegate
            {
                collectionChanged = true;
            };

            service.AddWatchCommand.Execute("Stock111");

            Assert.AreEqual(true, collectionChanged);
        }