public void Deveria_Chamar_Servico_de_Buscar_Turma_Test() { //arrange TurmaRepository .Setup(x => x.GetById(It.IsAny <int>())) .Returns(ObjectBuilder.CreateTurma()); //act TurmaService.GetById(1); //assert TurmaRepository.Verify(x => x.GetById(It.IsAny <int>()), Times.Once()); }
public void Deveria_Chamar_Servico_de_Remover_Turma_Test() { //arrange TurmaRepository .Setup(x => x.Delete(It.IsAny <int>())); //act TurmaService.Delete(1); UnitOfWork.Setup(x => x.Commit()); //assert TurmaRepository.Verify(x => x.Delete(It.IsAny <int>()), Times.Once()); UnitOfWork.Verify(x => x.Commit(), Times.Once()); }
public void Deveria_Chamar_Servico_de_Persistir_Turma_Test() { //arrange var turma = ObjectBuilder.CreateTurma(); TurmaRepository .Setup(x => x.Add(It.IsAny <Turma>())); UnitOfWork.Setup(x => x.Commit()); //act TurmaService.Add(new TurmaDTO(turma)); //assert TurmaRepository.Verify(x => x.Add(It.IsAny <Turma>()), Times.Once()); UnitOfWork.Verify(x => x.Commit(), Times.Once()); }
public void Deveria_Chamar_Servico_de_Buscar_Todas_Turmas_Test() { //arrange var turmas = new List <Turma>() { ObjectBuilder.CreateTurma() }; TurmaRepository .Setup(x => x.GetAll()) .Returns(turmas); //act TurmaService.GetAll(); //assert TurmaRepository.Verify(x => x.GetAll(), Times.Once()); }
public void Deveria_Chamar_Servico_de_Editar_Turma_Test() { //arrange var turma = ObjectBuilder.CreateTurma(); turma.Ano = 2016; TurmaRepository .Setup(x => x.Update(turma)); TurmaRepository .Setup(x => x.GetById(It.IsAny <int>())) .Returns(turma); UnitOfWork.Setup(x => x.Commit()); //act TurmaService.Update(new TurmaDTO(turma)); //assert TurmaRepository.Verify(x => x.Update(turma), Times.Once()); UnitOfWork.Verify(x => x.Commit(), Times.Once()); }