public void UpdateIndicatorNotExist() { var context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); IRepository <Indicator> indicatorRepo = new IndicatorRepository(context); var id = Guid.NewGuid(); string color = "red"; BaseCondition component = new Condition(); Indicator indicator = new Indicator(); indicator.Id = id; indicator.Color = color; indicator.Condition = component; indicatorRepo.Update(indicator); indicatorRepo.Save(); }
public IndicatorLoginDTO VerifyIfCodeIsOk(Indicator indicator, long code) { IndicatorUtil Util = new IndicatorService(); Indicator indicator1 = _repository.GetIndicatorByCPF(indicator.CPF); if (Util.ObjectIsNull(indicator1)) { throw new BadRequestException($"Nenhum usuário para este cpf: {indicator.CPF}, tente fazer login novamente"); } if (code != indicator1.confirmCode) { throw new BadRequestException($"Código: {code} não confere, tente gerar um novo código ou confira se digitou corretamente"); } try { // Gera o Token para indicador var token = TokenService.GenerateTokenIndicator(indicator); indicator1.IsConfirmed = AccountConfirm.CONFIRMED; _repository.Update(indicator1); IndicatorLoginDTO indicatorLogged = new IndicatorLoginDTO(); indicatorLogged.CPF = indicator1.CPF; indicatorLogged.Id = indicator1.Id; indicatorLogged.Email = indicator1.Email; indicatorLogged.Name = indicator1.Name; indicatorLogged.Status = indicator1.Status; indicatorLogged.IsConfirmed = indicator1.IsConfirmed; indicatorLogged.ConfirmCode = indicator1.confirmCode; indicatorLogged.Token = token; return(indicatorLogged); } catch (Exception e) { throw new Exception($"Algo deu errado, error: {e}"); } }
public void UpdateIndicatorOK() { var context = ContextFactory.GetMemoryContext(Guid.NewGuid().ToString()); IRepository <Indicator> indicatorRepo = new IndicatorRepository(context); var id = Guid.NewGuid(); string color = "red"; BaseCondition component = new Condition(); Indicator indicator = new Indicator(); indicator.Id = id; indicator.Color = color; indicator.Condition = component; indicatorRepo.Add(indicator); indicatorRepo.Save(); string colorUpdate = "yellow"; indicator.Color = colorUpdate; indicatorRepo.Update(indicator); var indicators = indicatorRepo.GetAll().ToList(); Assert.AreEqual(indicators[0].Color, "yellow"); }