public void TestTrackableCollection_IndexOf() { var b = new Simple("b"); var c = new Simple("c"); var coll = new TrackableCollection <Simple>() { new Simple("a"), b, new Simple("c"), b, c }; var idx = coll.IndexOf(b); Assert.AreEqual(1, idx); idx = coll.IndexOf(c); Assert.AreEqual(4, idx); }
public void TestTrackableCollection_Move(bool track) { var acc = new Accumulator("test"); var a = new Simple("a"); var b = new Simple("b"); var c = new Simple("c"); var coll = new TrackableCollection <Simple>(acc, track) { a, b, c, b, c, b, b }; coll.SafeMove(0, 3); Assert.AreEqual(2, coll.IndexOf(a)); coll.SafeMove(3, 3); coll.SafeMove(1, 40); // should result in an Add coll.Clear(); coll.Add(a); coll.SafeMove(0, 0); coll.SafeMove(0, 1); coll.Clear(); coll.SafeMove(0, 0); if (track) { Assert.AreEqual(13, acc.Records.Count); } else { Assert.AreEqual(0, acc.Records.Count); } }
public void TestTrackableCollection_Move_OutOfRange(bool track) { var acc = new Accumulator("test"); var a = new Simple("a"); var b = new Simple("b"); var c = new Simple("c"); var coll = new TrackableCollection <Simple>(acc, track) { a, b, c, b, c, b, b }; coll.SafeMove(0, 10); Assert.AreEqual(6, coll.IndexOf(a)); if (track) { Assert.AreEqual(8, acc.Records.Count); } else { Assert.AreEqual(0, acc.Records.Count); } }