public void Deve_lancar_exception() { Action act = () => { _service.RematricularAsync(_alunoId, _responsavel.EntityId, _escolaId, _salaId).Wait(); }; act.Should().Throw <ResponsavelNaoEncontradoException>(); }
public Rematricular_aluno() { _pessoaFisica = PessoaFisicaStub.PessoaMenorDeIdade; _responsavel = PessoaFisicaStub.PessoaMaiorDeIdade; _aluno = new Aluno(_alunoId, _pessoaFisica, _responsavel, _matricula); _aluno.Transferir(); _escola = new Escola(_escolaId, _escolaNome); _escola.AdicionarSala(_salaId, _salaFaseAno, Turno.Matutino); var mockAlunoRepository = new Mock <IAlunoRepository>(); var mockPessoaFisicaRepository = new Mock <IPessoaFisicaRepository>(); var mockEscolaRepository = new Mock <IEscolaRepository>(); var mockMatriculaService = new Mock <IMatriculaService>(); mockAlunoRepository.Setup(x => x.GetByEntityIdAsync(It.IsAny <Guid>())) .Returns(Task.FromResult(_aluno)); mockAlunoRepository.Setup(x => x.AddAsync(It.IsAny <Aluno>())) .Callback((Aluno a) => { _aluno = a; }); mockPessoaFisicaRepository.Setup(x => x.GetByEntityIdAsync(It.IsAny <Guid>())) .Returns((Guid entityId) => { if (entityId == _pessoaFisica.EntityId) { return(Task.FromResult(_pessoaFisica)); } if (entityId == _responsavel.EntityId) { return(Task.FromResult(_responsavel)); } return(Task.FromResult <PessoaFisica>(null)); }); mockEscolaRepository.Setup(x => x.GetByEntityIdAsync(It.IsAny <Guid>())) .Returns(Task.FromResult(_escola)); mockMatriculaService.Setup(x => x.GerarMatriculaAsync()) .Returns(Task.FromResult(_matricula)); _service = new AlunoService(mockAlunoRepository.Object, mockPessoaFisicaRepository.Object, mockEscolaRepository.Object, mockMatriculaService.Object); TestAsyncHelper.CallSync(() => _service.RematricularAsync(_alunoId, _responsavel.EntityId, _escolaId, _salaId).Wait()); }