Advertisement
Mateus_Costa

Untitled

Apr 19th, 2019
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 KB | None | 0 0
  1. namespace TesteApp
  2. {
  3.     /// <summary>
  4.     /// Classe de testes
  5.     /// </summary>
  6.     public static class Teste
  7.     {
  8.         public static bool PodeAtualizar(Usuario user)
  9.         {
  10.             return (user.Operacoes & Operacoes.Atualizar) != 0;
  11.         }
  12.  
  13.         public static bool PodeLer(Usuario user)
  14.         {
  15.             return (user.Operacoes & Operacoes.Ler) != 0;
  16.         }
  17.  
  18.         public static bool PodeEscrever(Usuario user)
  19.         {
  20.             return (user.Operacoes & Operacoes.Escrever) != 0;
  21.         }
  22.  
  23.         public static bool PodeDeletar(Usuario user)
  24.         {
  25.             return (user.Operacoes & Operacoes.Deletar) != 0;
  26.         }
  27.     }
  28.  
  29.     class Program
  30.     {
  31.         static void Main(string[] args)
  32.         {
  33.             var funcionario = new Funcionario();
  34.  
  35.             Console.WriteLine(Teste.PodeAtualizar(funcionario)); // imprime verdadeiro
  36.             Console.WriteLine(Teste.PodeDeletar(funcionario)); // imprime falso, funcionário não tem o poder de deletar!
  37.             Console.WriteLine(Teste.PodeLer(funcionario)); // imprime verdadeiro
  38.             Console.WriteLine(Teste.PodeEscrever(funcionario)); // imprime verdadeiro
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement