public void Test_Add_ObjectsWithSameBeat() { var list = new BeatObjectList <BPM>(); list.Add(new BPM(100, 0)); Assert.Throws <ArgumentException>(() => list.Add(new BPM(200, 0))); }
public void Test_Clear_ClearsList() { var list = new BeatObjectList <BPM>(); list.Add(new BPM(100, 0)); list.Add(new BPM(100, 5)); list.Clear(); Assert.AreEqual(0, list.Count); }
public void Test_Clear_FiresClearedEvent() { var list = new BeatObjectList <BPM>(); list.Add(new BPM(100, 0)); list.Add(new BPM(100, 5)); var calls = 0; list.Cleared += delegate { calls++; }; list.Clear(); Assert.AreEqual(1, calls); Assert.AreEqual(0, list.Count); }
public void Test_Remove_ObjectExists() { var list = new BeatObjectList <BPM>(); var bpm = new BPM(100, 0); list.Add(bpm); Assert.IsTrue(list.Remove(bpm)); Assert.AreEqual(0, list.Count); }
public void Test_Add_InsertsObject() { var list = new BeatObjectList <BPM>(); var bpm = new BPM(100, 0); list.Add(bpm); Assert.AreEqual(1, list.Count); var array = list.ToArray(); Assert.AreSame(array[0], bpm); }
public void Test_Add_FiresAddedEvent() { var list = new BeatObjectList <BPM>(); var bpm = new BPM(100, 0); var calls = 0; list.Added += (o, e) => { var args = e as ObjectListEventArgs <BPM>; Assert.AreSame(bpm, args.Object); calls++; }; list.Add(bpm); Assert.AreEqual(calls, 1); }
public void Test_RemoveAtBeat_FiresRemovedEvent() { var list = new BeatObjectList <BPM>(); var removedList = new List <BPM>(); var bpm = new BPM(100, 0); list.Add(bpm); list.Removed += (o, e) => { var args = e as ObjectListEventArgs <BPM>; removedList.Add(args.Object); }; list.RemoveAtBeat(bpm.Beat.Value + 100); // Verify the event wasn't fired when no object is removed. Assert.IsEmpty(removedList); list.RemoveAtBeat(bpm.Beat); Assert.AreEqual(1, removedList.Count); Assert.AreSame(bpm, removedList[0]); }
public void Test_Remove_FiresRemovedEvent() { var list = new BeatObjectList <BPM>(); var removedList = new List <BPM>(); var bpm = new BPM(100, 0); list.Add(bpm); list.Removed += (o, e) => { var args = e as ObjectListEventArgs <BPM>; removedList.Add(args.Object); }; list.Remove(new BPM(100, 0)); // Verify the event doesn't fire when an equivalent but different object is removed. Assert.IsEmpty(removedList); list.Remove(bpm); Assert.AreEqual(1, removedList.Count); Assert.AreSame(bpm, removedList[0]); }
public void Test_Add_CantBeNull() { var list = new BeatObjectList <BPM>(); Assert.Throws <ArgumentNullException>(() => list.Add(null)); }