Exemplo n.º 1
0
        public void TickerSymbolGetsConvertedToUppercase()
        {
            WatchListService service = new WatchListService(new MockMarketFeedService());

            service.AddWatchCommand.Execute("StockInMixedCase");

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

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

            Assert.AreEqual(1, service.RetrieveWatchList().Count);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
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]);
        }
Exemplo n.º 5
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]);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
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]);
        }
Exemplo n.º 8
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 Delete_ShouldReturnTrueforVaildId()
        {
            // Arrange
            this.mockWatchListRepository.Setup(x => x.Delete(It.IsAny <int>())).Returns(true);
            var service = new WatchListService(mockWatchListRepository.Object);

            // Act
            var actual = service.Delete(1);

            //Assert
            Assert.True(actual);
        }
Exemplo n.º 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);
        }
        public void GetAll_ShouldReturnListOfWatchListAsExpected()
        {
            // Arrange
            mockWatchListRepository.Setup(x => x.GetAll()).Returns(this.GetMoviesList);
            var service  = new WatchListService(mockWatchListRepository.Object);
            var expected = this.GetMoviesList().Count;

            // Act
            var actual = service.GetAll().Count();

            //Assert
            Assert.Equal(expected, actual);
        }
        public void Get_ShouldReturnWhishListAsExpected()
        {
            // Arrange
            var expectedResult = this.GetMoviesList().First();

            mockWatchListRepository.Setup(x => x.Get(It.IsAny <int>())).Returns(expectedResult);
            var service = new WatchListService(mockWatchListRepository.Object);

            // Act
            var actual = service.GetWatchListById(1);

            //Assert
            Assert.NotNull(actual);
            Assert.Equal(expectedResult.Id, actual.Id);
            Assert.Equal(expectedResult.Comments, actual.Comments);
        }
Exemplo n.º 13
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);
        }
        public void Update_ShouldUpdateForValidId()
        {
            // Arrange
            var expected  = 1;
            var WatchList = new MovieList()
            {
                Id       = 1,
                Comments = "Good"
            };

            this.mockWatchListRepository.Setup(x => x.Update(It.IsAny <MovieList>())).Returns(1);
            var service = new WatchListService(mockWatchListRepository.Object);

            // Act
            var actual = service.Update(WatchList);

            //Assert
            Assert.Equal(expected, actual);
        }
        public void Save_WatchListAsExpected()
        {
            // Arrange
            var expected  = 1;
            var WatchList = new MovieList()
            {
                Id       = 1,
                Comments = "Good"
            };

            mockWatchListRepository.Setup(x => x.Save(It.IsAny <MovieList>())).Returns(expected);
            var service = new WatchListService(mockWatchListRepository.Object);

            // Act
            var actual = service.Save(WatchList);

            //Assert
            Assert.Equal(expected, actual);
        }