public void DeleteConsultationServiceTest() { //Arrange Consultation Consultation = null; //Fake do repositório var repositoryFake = new Mock<IConsultationRepository>(); repositoryFake.Setup(r => r.Delete(1)).Returns(Consultation); IConsultationService service = new ConsultationService(repositoryFake.Object); //Action var ConsultationFake = service.Delete(1); //Assert repositoryFake.Verify(r => r.Delete(1)); Assert.IsNull(ConsultationFake); }
public void RetrieveConsultationServiceTest() { //Arrange Consultation Consultation = ObjectMother.GetConsultation(); //Fake do repositório var repositoryFake = new Mock<IConsultationRepository>(); repositoryFake.Setup(r => r.Get(1)).Returns(Consultation); IConsultationService service = new ConsultationService(repositoryFake.Object); //Action var ConsultationFake = service.Retrieve(1); //Assert repositoryFake.Verify(r => r.Get(1)); Assert.IsNotNull(ConsultationFake); }
public void CreateConsultationServiceValidationAndPersistenceTest() { //Arrange Consultation Consultation = ObjectMother.GetConsultation(); //Fake do repositório var repositoryFake = new Mock<IConsultationRepository>(); repositoryFake.Setup(r => r.Save(Consultation)).Returns(Consultation); //Fake do dominio var ConsultationFake = new Mock<Consultation>(); ConsultationFake.As<IObjectValidation>().Setup(b => b.Validate()); IConsultationService service = new ConsultationService(repositoryFake.Object); //Action service.Create(ConsultationFake.Object); //Assert ConsultationFake.As<IObjectValidation>().Verify(b => b.Validate()); repositoryFake.Verify(r => r.Save(ConsultationFake.Object)); }