public void IntegrationTest_GetTotalMovies_Return_QtdMovies(string titleMovie, int expected) { //I am Violating the DRY principle Here ALL the Time //Don’t-Repeat-Yourself (DRY) design principle //Arrange var calculator = new Calculator.Service.Concrete.Calculator(); //Action var result = calculator.GetMoviesTotal(titleMovie); //Assert Assert.AreEqual(expected, result); }
public void MockingObjet_GetTotalMovies_Return_QtdMovies(string titleMovie, int expected, string dataHardCode) { //I am Violating the DRY principle Here ALL the Time //Don’t-Repeat-Yourself (DRY) design principle //Arrange //Create in Memory Fake Object and Use this isolate object //In a Mock Obj, I wanna tell it What I want to do, when I expected to do when I call a particular Method var serviceMock = new Mock <IGetServices>(); serviceMock.Setup(s => s.GetServiceQtdMovies(It.IsAny <string>())).Returns(dataHardCode); //Action var calculator = new Calculator.Service.Concrete.Calculator(); //This Is the Magic tha Mock Do calculator.Service = serviceMock.Object; var result = calculator.GetMoviesTotal(titleMovie); //Assert Assert.AreEqual(expected, result); }