public void ListNoAllocTest() { MemoryWatch watch = new MemoryWatch(); var randomList = GetRandomList(); var listeners = new ListNoAlloc <IEvent> (10); var handler = new HandlerEvent(); listeners.Add(handler); watch.Start(); int l = 0; for (int j = 0; j < Seconds; ++j) { for (int i = 0; i < FramesPerSecond; ++i) { listeners.Add(handler); listeners.ForEach(x => x.EventHandler(true)); listeners.Remove(handler); l += 1; } } watch.Stop(); results.Add(watch.GetAllocationDesc($"Event add/remove using ListNoAlloc for each frame at {FramesPerSecond} FPS for {Seconds} s of game")); // Just so we force l to be used Assert.Less(0, l); }
public void RemoveFail() { var list = new ListNoAlloc <int>(3); Assert.AreEqual(0, list.Count); list.Add(2); Assert.False(list.Remove(3)); Assert.AreEqual(1, list.Count); }
public void Remove() { var list = new ListNoAlloc <int>(3); Assert.AreEqual(0, list.Count); list.Add(2); list.Remove(2); Assert.AreEqual(0, list.Count); }