public void ReturnCorrectList_WhenRetryIsSelected(string inputParameters, string selectorResult, string readFromSelector) { // Arrange var parameters = inputParameters.Split('|').ToList(); var name = parameters[0]; var description = parameters[2]; var year = int.Parse(parameters[3]); var duration = int.Parse(parameters[4]); var movieMock = new Mock <Movie>(); var selectorMock = new Mock <IItemSelector>(); var movieServicesMock = new Mock <IMovieServices>(); selectorMock .Setup(s => s.DisplayItems(It.IsAny <List <string> >())) .Returns(selectorResult); selectorMock .Setup(s => s.ReadAtPosition(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <int>())) .Returns(readFromSelector); movieServicesMock .Setup(ms => ms.UpdateMovie(name, description, year, duration)); // Act var sut = new UpdateMovie(selectorMock.Object, movieServicesMock.Object); var result = sut.Execute(parameters); // Assert CollectionAssert.AreEqual(parameters, result.ToList()); }
public void EnsureUpdateMethod_IsCalled(string inputParameters, string selectorResult, string readFromSelector, string expected) { // Arrange var parameters = inputParameters.Split('|').ToList(); var name = parameters[0]; var description = parameters[2]; var year = int.Parse(parameters[3]); var duration = int.Parse(parameters[4]); var movieMock = new Mock <Movie>(); var selectorMock = new Mock <IItemSelector>(); var movieServicesMock = new Mock <IMovieServices>(); selectorMock .Setup(s => s.DisplayItems(It.IsAny <List <string> >())) .Returns(selectorResult); selectorMock .Setup(s => s.ReadAtPosition(It.IsAny <int>(), It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <int>())) .Returns(readFromSelector); // Act var sut = new UpdateMovie(selectorMock.Object, movieServicesMock.Object); var result = sut.Execute(parameters); // Assert movieServicesMock.Verify(ms => ms.UpdateMovie(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>()), Times.Once); }