public void GetSunset_OnValidDate_ReturnExpectedDateTime() { //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.GetServiceDate(It.IsAny <DateTime>())).Returns(goodData); DateTime date = new DateTime(2016, 09, 10); DateTime expected = new DateTime(2016, 09, 10, 16, 42, 49); //Action var calculator = new Calculator.Service.Concrete.Calculator(); //This Is the Magic tha Mock Do calculator.Service = serviceMock.Object; var result = calculator.GetSunset(date); //Assert Assert.AreEqual(expected, result); }
public void ServiceSunsetCalculator_ImplementsISunsetCalculator() { //Arrange values to Initiate de TDD var srvSunsetCalculator = new Calculator.Service.Concrete.Calculator(); //Actions and/or Methods //Assert Assert.IsInstanceOf <ICalculator>(srvSunsetCalculator); }
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); }