예제 #1
0
        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));
        }