public void TickerSymbolGetsConvertedToUppercase()
        {
            WatchListService service = new WatchListService(new MockMarketFeedService());

            service.AddWatchCommand.Execute("StockInMixedCase");

            Assert.AreEqual<string>("StockInMixedCase".ToUpper(CultureInfo.InvariantCulture), service.RetrieveWatchList()[0]);
        }
        public void AddingSameSymbolTwiceOnlyAddsItOnceToTheList()
        {
            WatchListService service = new WatchListService(new MockMarketFeedService());

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

            Assert.AreEqual(1, service.RetrieveWatchList().Count);
        }
        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);
        }
        public void NullOrEmptyStringIsNotAddedToList()
        {
            WatchListService service = new WatchListService(new MockMarketFeedService());

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

            Assert.AreEqual(0, service.RetrieveWatchList().Count);
        }
        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 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);
        }
        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]);

        }
        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]);
        }
        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]);
        }
Beispiel #10
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);
        }