Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections.Generic;
- using System.Linq;
- using hashes;
- using NUnitLite;
- namespace ghost
- {
- class Program
- {
- static void Main(string[] args)
- {
- AssertThatDoMagicBreaksHashSet<Vector, GhostsTask>();
- AssertThatDoMagicBreaksHashSet<Segment, GhostsTask>();
- AssertThatDoMagicBreaksHashSet<Cat, GhostsTask>();
- AssertThatDoMagicBreaksHashSet<Document, GhostsTask>();
- AssertThatDoMagicBreaksHashSet<Robot, GhostsTask>();
- }
- private static void AssertThatDoMagicBreaksHashSet<TItem, TGhostsTask>() where TGhostsTask : IMagic, IFactory<TItem>, new()
- {
- TGhostsTask task = new TGhostsTask();
- var ghostItem = task.Create();
- var set = new HashSet<TItem> { ghostItem };
- set.Contains(task.Create());
- task.DoMagic();
- int count = set.Count;
- var temp = set.ToArray()[0];
- bool flag = set.Contains(ghostItem);
- //Assert.AreEqual(1, set.Count, "HashSet still contains some element after DoMagic()");
- //Assert.AreEqual(ghostItem, set.ToArray()[0], "The single item in HashSet equals ghostItem after DoMagic()");
- //Assert.IsFalse(set.Contains(ghostItem), "ghostItem should disappear from HashSet after DoMagic()");
- set.Add(ghostItem);
- int count2 = set.Count;
- //Assert.AreEqual(2, set.Count, "HashSet Add and Count should work incorrectly after DoMagic()");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement