コード例 #1
0
        public void CallGetIdOnMovieServices(string input, string selectorResult, string expected)
        {
            //Arrange
            var parameters       = input.Split().ToList();
            var itemSelectorMock = new Mock <IItemSelector>();

            var movieServicesMock = new Mock <IMovieServices>();

            movieServicesMock.Setup(movieServices => movieServices.GetID(It.IsAny <string>())).Returns(default(int));
            movieServicesMock.Setup(movieServices => movieServices.GetMovieNamesByCityIDGenreID(1, 5)).Returns(new List <string>());
            //Act
            var chooseMovie = new ChooseMovie(itemSelectorMock.Object, movieServicesMock.Object);
            var result      = chooseMovie.Execute(parameters);

            //Assert
            movieServicesMock.Verify(movieService => movieService.GetID(It.IsAny <string>()), Times.Once);
        }
コード例 #2
0
        public void ReturnCorrectList_WhenHomeIsSelected(string input, string selectorResult, string expected)
        {
            //Arrange
            var parameters = input.Split().ToList();

            var itemSelectorMock = new Mock <IItemSelector>();

            itemSelectorMock.Setup(itemSelector => itemSelector.DisplayItems(It.IsAny <List <string> >())).Returns(selectorResult);

            var movieServicesMock = new Mock <IMovieServices>();

            movieServicesMock.Setup(movieServices => movieServices.GetID("Titanic")).Returns(1);
            movieServicesMock.Setup(movieServices => movieServices.GetMovieNamesByCityIDGenreID(1, 5)).Returns(new List <string>());

            //Act
            var chooseMovie = new ChooseMovie(itemSelectorMock.Object, movieServicesMock.Object);
            var result      = chooseMovie.Execute(parameters);

            //Assert
            Assert.AreEqual(expected, result.First());
        }