public Funcionario(int id, string nome, string cpf) { ID = id; Nome = nome; Cpf = cpf; RepositoryFuncionario.AddFuncionario(this); }
public void Get_BuscaTodosOsFuncionarios_True() { var options = new DbContextOptionsBuilder <ContextEmpresa>() .UseInMemoryDatabase(databaseName: "Get_funcionarios") .Options; // Insert seed data into the database using one instance of the context using (var context = new ContextEmpresa(options)) { context.Funcionarios.Add(new Funcionario { Cpf = 111111111, Nome = "Funcionario 1" }); context.Funcionarios.Add(new Funcionario { Cpf = 222222222, Nome = "Funcionario 2" }); context.Funcionarios.Add(new Funcionario { Cpf = 333333333, Nome = "Funcionario 3" }); context.SaveChanges(); } // Use a clean instance of the context to run the test using (var context = new ContextEmpresa(options)) { var service = new RepositoryFuncionario(context); var result = service.Get(); //Assert.AreEqual(3, result.Count()); } }
public void Put_AtualizaDadoDoFuncionario_True() { var options = new DbContextOptionsBuilder <ContextEmpresa>() .UseInMemoryDatabase(databaseName: "Put_funcionarios") .Options; // Insert seed data into the database using one instance of the context using (var context = new ContextEmpresa(options)) { context.Funcionarios.Add(new Funcionario { Cpf = 111111111, Nome = "Funcionario 1" }); context.Funcionarios.Add(new Funcionario { Cpf = 222222222, Nome = "Funcionario 2" }); context.Funcionarios.Add(new Funcionario { Cpf = 333333333, Nome = "Funcionario 3" }); context.SaveChanges(); } // Use a clean instance of the context to run the test using (var context = new ContextEmpresa(options)) { var service = new RepositoryFuncionario(context); var funcionario = new Funcionario { Cpf = 111111111, Nome = "Funcionario Modificado" }; service.Put(funcionario); } using (var context = new ContextEmpresa(options)) { var service = new RepositoryFuncionario(context); var result = service.GetByCPF(111111111); //Assert.AreEqual("Funcionario Modificado", result.Nome); } }
public void Add_AdicionarFuncionario_True() { var options = new DbContextOptionsBuilder <ContextEmpresa>() .UseInMemoryDatabase(databaseName: "Add_funcionario") .Options; // Run the test against one instance of the context using (var context = new ContextEmpresa(options)) { var service = new RepositoryFuncionario(context); var funcionario = new Funcionario { Cpf = 111111111, Nome = "Novo Funcionario" }; service.Add(funcionario); } // Use a separate instance of the context to verify correct data was saved to database using (var context = new ContextEmpresa(options)) { Assert.AreEqual(1, context.Funcionarios.Count()); Assert.AreEqual("Novo Funcionario", context.Funcionarios.Single().Nome); //Assert.AreEqual(111111111, context.Funcionarios.Single().Cpf); } }
public static List <Funcionario> Funcionarios() { return(RepositoryFuncionario.Funcionarios()); }
//retorna funcionario pro view public static List <Funcionario> returnFunc() { return(RepositoryFuncionario.returnFunc()); }
public ApplicationFuncionario(ContextEmpresa context, IMapper mapper) { _funcionarioRepositorio = new RepositoryFuncionario(context); _context = context; _mapper = mapper; }
public oFuncionario() { _Repository = new RepositoryFuncionario(); }