public void ActualizarParticipanteDatosErroneosTest() { //Arrange var fakeParticipante = TestHelper.ObtenerParticipanteNombreVacio(); var mockParticipantesRepository = new Mock <IParticipantesRepository>(); var mockUnitOfWork = new Mock <IUnitOfWork>(); var businessLogic = new ParticipantesService(mockUnitOfWork.Object, mockParticipantesRepository.Object, null, null); //Act businessLogic.ModificarParticipante(fakeParticipante.Id, fakeParticipante); //Assert mockParticipantesRepository.VerifyAll(); }
public void AgregarParticipanteNombreVacioTest() { var fakeParticipante = TestHelper.ObtenerParticipanteNombreVacio(); var mockParticipantesRepository = new Mock <IParticipantesRepository>(); var mockUnitOfWork = new Mock <IUnitOfWork>(); mockParticipantesRepository .Setup(r => r.Insert(fakeParticipante)); var businessLogic = new ParticipantesService(mockUnitOfWork.Object, mockParticipantesRepository.Object, null, null); //Act businessLogic.AgregarParticipante(fakeParticipante); //Assert mockParticipantesRepository.VerifyAll(); }
private void ProcessarParticipante(string codigoParticipante) { if (String.IsNullOrWhiteSpace(codigoParticipante)) { return; } if (!dadosArquivoContmaticService.RegistroJaExistente("0150", codigoParticipante)) { // Caso o cliente ou fornecedor ainda não tenha sido processado, // persiste o mesmo para posterior geração do arquivo this.UpdateStatusAsynchronousExecution("Gerando Registro 0150"); Registro0150 reg0150 = ParticipantesService.GetRegistro0150(codigoParticipante); if (reg0150 != null) { dadosArquivoContmaticService.PersistirRegistro(reg0150); } } }
public void BorrarParticipanteNoExistenteErrorTest() { var fakeParticipante = TestHelper.ObtenerParticipanteFalso(); var fakeParticipanteId = fakeParticipante.Id; var mockUnitOfWork = new Mock <IUnitOfWork>(); var mockParticipantesRepository = new Mock <IParticipantesRepository>(); mockParticipantesRepository .Setup(r => r.ObtenerParticipantePorId(fakeParticipanteId)).Returns((Participante)null); var businessLogic = new ParticipantesService(mockUnitOfWork.Object, mockParticipantesRepository.Object, null, null); //Act businessLogic.BorrarParticipante(fakeParticipanteId); //Assert mockParticipantesRepository.VerifyAll(); }
public void AgregarParticipanteDeporteNoExistenteErrorTest() { var fakeParticipante = TestHelper.ObtenerParticipanteFalso(); var mockParticipantesRepository = new Mock <IParticipantesRepository>(); var mockDeportesRepository = new Mock <IDeportesRepository>(); var mockUnitOfWork = new Mock <IUnitOfWork>(); mockDeportesRepository .Setup(r => r.ObtenerDeportePorNombre(fakeParticipante.Deporte.Nombre)).Returns((Deporte)null); mockParticipantesRepository.Setup(r => r.Insert(fakeParticipante)); var businessLogic = new ParticipantesService(mockUnitOfWork.Object, mockParticipantesRepository.Object, mockDeportesRepository.Object, null); //Act businessLogic.AgregarParticipante(fakeParticipante); //Assert mockParticipantesRepository.VerifyAll(); }
public void ObtenerParticipantesNullTest() { //Arrange List <Participante> participantesEsperados = null; var mockParticipantesRepository = new Mock <IParticipantesRepository>(); var mockUnitOfWork = new Mock <IUnitOfWork>(); mockParticipantesRepository .Setup(r => r.ObtenerParticipantes()) .Returns(participantesEsperados); var businessLogic = new ParticipantesService(mockUnitOfWork.Object, mockParticipantesRepository.Object, null, null); //Act IEnumerable <Participante> obtainedResult = businessLogic.ObtenerParticipantes(); //Assert mockParticipantesRepository.VerifyAll(); Assert.IsNull(obtainedResult); }
public void ObtenerParticipantePorIdErrorNotFoundTest() { //Arrange var fakeId = System.Guid.NewGuid(); var mockParticipantesRepository = new Mock <IParticipantesRepository>(); var mockUnitOfWork = new Mock <IUnitOfWork>(); mockParticipantesRepository .Setup(r => r.ObtenerParticipantePorId(fakeId)) .Returns((Participante)null); var businessLogic = new ParticipantesService(mockUnitOfWork.Object, mockParticipantesRepository.Object, null, null); //Act Participante obtainedResult = businessLogic.ObtenerParticipantePorId(fakeId); //Assert mockParticipantesRepository.VerifyAll(); Assert.IsNull(obtainedResult); }
private void ProcessarParticipante(string codigoParticipante, string codEmp) { if (String.IsNullOrWhiteSpace(codigoParticipante)) { return; } Registro0150 reg0150 = ParticipantesService.GetRegistro0150(codigoParticipante); if (reg0150 != null) { if (contribuintes.Where(c => c.codEmp == codEmp && c.registro.ToString() == reg0150.ToString()).Count() == 0) { // Caso o cliente ou fornecedor ainda não tenha sido processado, // persiste o mesmo para posterior geração do arquivo contribuintes.Add(new validacao { codEmp = codEmp, registro = reg0150 }); } } }
public void ActualizarParticipanteNuevoNombreYaExistenteTest() { //Arrange var fakeParticipante = TestHelper.ObtenerParticipanteFalso(); var mockParticipantesRepository = new Mock <IParticipantesRepository>(); var mockUnitOfWork = new Mock <IUnitOfWork>(); mockParticipantesRepository .Setup(r => r.ObtenerParticipantePorId(fakeParticipante.Id)) .Returns(fakeParticipante); mockParticipantesRepository .Setup(r => r.ObtenerParticipantePorDeporte(fakeParticipante.Deporte.Nombre, fakeParticipante.Nombre)) .Throws(new ExisteParticipanteException()); var businessLogic = new ParticipantesService(mockUnitOfWork.Object, mockParticipantesRepository.Object, null, null); //Act businessLogic.ModificarParticipante(fakeParticipante.Id, fakeParticipante); //Assert mockParticipantesRepository.VerifyAll(); }
public void ObtenerParticipantePorNombreOkTest() { //Arrange var fakeParticipante = TestHelper.ObtenerParticipanteFalso(); var fakeNombre = fakeParticipante.Nombre; var mockParticipantesRepository = new Mock <IParticipantesRepository>(); var mockUnitOfWork = new Mock <IUnitOfWork>(); mockParticipantesRepository .Setup(r => r.ObtenerParticipantePorNombre(fakeNombre)) .Returns(fakeParticipante); var businessLogic = new ParticipantesService(mockUnitOfWork.Object, mockParticipantesRepository.Object, null, null); //Act Participante obtainedResult = businessLogic.ObtenerParticipantePorNombre(fakeNombre); //Assert mockParticipantesRepository.VerifyAll(); Assert.IsNotNull(obtainedResult); Assert.AreEqual(fakeNombre, obtainedResult.Nombre); }