Advertisement
Schnuk

Untitled

Feb 28th, 2021
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using hashes;
  4. using NUnitLite;
  5.  
  6. namespace ghost
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. AssertThatDoMagicBreaksHashSet<Vector, GhostsTask>();
  13.  
  14. AssertThatDoMagicBreaksHashSet<Segment, GhostsTask>();
  15.  
  16. AssertThatDoMagicBreaksHashSet<Cat, GhostsTask>();
  17.  
  18. AssertThatDoMagicBreaksHashSet<Document, GhostsTask>();
  19.  
  20. AssertThatDoMagicBreaksHashSet<Robot, GhostsTask>();
  21. }
  22.  
  23. private static void AssertThatDoMagicBreaksHashSet<TItem, TGhostsTask>() where TGhostsTask : IMagic, IFactory<TItem>, new()
  24. {
  25. TGhostsTask task = new TGhostsTask();
  26. var ghostItem = task.Create();
  27.  
  28. var set = new HashSet<TItem> { ghostItem };
  29. set.Contains(task.Create());
  30.  
  31. task.DoMagic();
  32. int count = set.Count;
  33. var temp = set.ToArray()[0];
  34. bool flag = set.Contains(ghostItem);
  35. //Assert.AreEqual(1, set.Count, "HashSet still contains some element after DoMagic()");
  36. //Assert.AreEqual(ghostItem, set.ToArray()[0], "The single item in HashSet equals ghostItem after DoMagic()");
  37. //Assert.IsFalse(set.Contains(ghostItem), "ghostItem should disappear from HashSet after DoMagic()");
  38.  
  39. set.Add(ghostItem);
  40. int count2 = set.Count;
  41. //Assert.AreEqual(2, set.Count, "HashSet Add and Count should work incorrectly after DoMagic()");
  42. }
  43. }
  44. }
  45.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement