Пример #1
0
 public void InicializarTest()
 {
     admin1 = new Admin()
     {
         AdminId = 1,
         Email = "*****@*****.**",
         Login = "******",
     };
 }
Пример #2
0
        public void GarantirQue2AdminSaoIguaisQuandoTemMesmoLogin()
        {
            admin2 = new Admin()
            {
                Login = "******"
            };

            Assert.AreEqual(admin1.Login, admin2.Login);
            Assert.AreEqual(admin1, admin2);
        }
Пример #3
0
        public void GarantirQue2AdminSaoIguaisQuandoTemMesmoId()
        {
            admin2 = new Admin()
            {
                AdminId = 1
            };

            Assert.AreEqual(admin1.AdminId, admin2.AdminId);
            Assert.AreEqual(admin1,admin2);
        }
Пример #4
0
        public void GarantirQue2AdminSaoIguaisQuandoTemMesmoEmail()
        {
            admin2 = new Admin()
            {
                Email = "*****@*****.**"
            };

            Assert.AreEqual(admin1.Email, admin2.Email);
            Assert.AreEqual(admin1, admin2);
        }
Пример #5
0
 public void Add(Admin admin)
 {
     var validacao = this.Admins.Where(w => w.Login.ToUpper().Equals(admin.Login.ToUpper()) ||
                                            w.Email.ToUpper().Equals(admin.Email.ToUpper()));
     if (validacao.Any())
     {
         throw  new InvalidOperationException("Administrador já cadastrado com esse login ou e-mail");
     }
     _vestContext.ADMIN.Add(admin);
     _vestContext.SaveChanges();
 }
Пример #6
0
        public void InicializarTest()
        {
            _adminRepository = new EFAdminRepository(_vestContext);

            _inserirAdm = new Admin()
            {
                Email = "*****@*****.**",
                Login = "******",
                Senha = "123",
                NomeTratamento = "João Effting"
            };
        }
Пример #7
0
        public void Update(Admin admin)
        {
            var validaca = this.Admins.Where(w => w.AdminId != admin.AdminId &&
                                                  (w.Login.ToUpper().Equals(admin.Login.ToUpper()) ||
                                                   w.Email.ToUpper().Equals(admin.Email.ToUpper())));

            if (validaca.Any())
            {
                throw new InvalidOperationException("Administrador já cadastrado com esse login ou e-mail");
            }

            _vestContext.Entry(admin).State = EntityState.Modified;
            _vestContext.SaveChanges();
        }
Пример #8
0
        public void NaoPodeAlterarAdminComMesmoEmailTest()
        {
            //Ambiente
            _adminRepository.Add(_inserirAdm);

            var adminInserir2 = new Admin()
            {
                Email = "*****@*****.**"
            };

            _adminRepository.Add(adminInserir2);

            var adminAlterar = _adminRepository.Admins
                .Where(w => w.AdminId.Equals(_inserirAdm.AdminId)).FirstOrDefault();
            //Ação

            adminAlterar.NomeTratamento = "*****@*****.**";

            _adminRepository.Update(adminAlterar);
        }
Пример #9
0
        public void NaoPodeAlterarAdminComMesmoLoginTest()
        {
            //Ambiente
            _adminRepository.Add(_inserirAdm);

            var adminInserir2 = new Admin()
            {
                Login = "******"
            };

            _adminRepository.Add(adminInserir2);

            var adminAlterar = _adminRepository.Admins
                .Where(w => w.AdminId.Equals(_inserirAdm.AdminId)).FirstOrDefault();
            //Ação

            adminAlterar.NomeTratamento = "admin";

            _adminRepository.Update(adminAlterar);
        }
Пример #10
0
 public void NaoPodeInserirAdminComMesmoLoginTest()
 {
     //Ambiente
     var adminInserir2 = new Admin()
     {
         Login = _inserirAdm.Login
     };
     _adminRepository.Add(_inserirAdm);
     //Ação
     _adminRepository.Add(adminInserir2);
 }
Пример #11
0
 public void NaoPodeInserirAdminComMesmoEmailTest()
 {
     //Ambiente
     var adminInserir2 = new Admin()
     {
         Email = _inserirAdm.Email
     };
     _adminRepository.Add(_inserirAdm);
     //Ação
     _adminRepository.Add(adminInserir2);
 }