corp0

snipt

Jun 29th, 2021
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 KB | None | 0 0
  1. using System;
  2.  
  3. public class Program
  4. {
  5.     [Flags]
  6.     public enum TraumaDamages
  7.     {
  8.         NONE = 0,
  9.         SLASH = 1 << 1,
  10.         PIERCE = 1 << 2,
  11.         BURN = 1 << 3
  12.     }
  13.  
  14.     public static void Main()
  15.     {
  16.         var onlyBurn = TraumaDamages.BURN;
  17.         var onlySlash = TraumaDamages.SLASH;
  18.         var onlyPierce = TraumaDamages.PIERCE;
  19.         var testGroup1 = new TraumaDamages[]{onlyBurn, onlySlash, onlyPierce};
  20.         Test(testGroup1);
  21.        
  22.         Console.WriteLine("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
  23.        
  24.         var burnSlash = TraumaDamages.BURN | TraumaDamages.SLASH;
  25.         var burnPierce = TraumaDamages.BURN | TraumaDamages.PIERCE;
  26.         var slashPierce = TraumaDamages.SLASH | TraumaDamages.PIERCE;
  27.         var all = TraumaDamages.SLASH | TraumaDamages.PIERCE | TraumaDamages.BURN;
  28.         var testGroup2 = new TraumaDamages[]{burnSlash, burnPierce, slashPierce, all};
  29.         Test(testGroup2);
  30.     }
  31.  
  32.     public static void Test(TraumaDamages[] group)
  33.     {
  34.         var c = 0;
  35.         foreach (var testCase in group)
  36.         {
  37.             c++;
  38.             PerformTest(testCase, c);
  39.         }
  40.     }
  41.  
  42.     public static void PerformTest(TraumaDamages testee, int index)
  43.     {
  44.         Console.WriteLine("*******************************");
  45.         if (testee.HasFlag(TraumaDamages.BURN))
  46.         {
  47.             Console.WriteLine("Testing case: " + index.ToString() + ". Entered block: BURN");
  48.         }
  49.  
  50.         if (testee.HasFlag(TraumaDamages.SLASH))
  51.         {
  52.             Console.WriteLine("Testing case: " + index.ToString() + ". Entered block: SLASH");
  53.         }
  54.  
  55.         if (testee.HasFlag(TraumaDamages.PIERCE))
  56.         {
  57.             Console.WriteLine("Testing case: " + index.ToString() + ". Entered block: PIERCE");
  58.         }
  59.     }
  60. }
Add Comment
Please, Sign In to add comment