-
-
Notifications
You must be signed in to change notification settings - Fork 184
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #279 from adarapata/fix_allocation_on_tickables
Fix allocation on tickables
- Loading branch information
Showing
3 changed files
with
128 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
VContainer/Assets/VContainer/Tests/Unity/PlayerLoopItemTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
using System.Collections.Generic; | ||
using NUnit.Framework; | ||
using UnityEngine.TestTools.Constraints; | ||
using VContainer.Unity; | ||
using Is = NUnit.Framework.Is; | ||
|
||
namespace VContainer.Tests.Unity | ||
{ | ||
public class PlayerLoopItemTest | ||
{ | ||
private class Ticker : ITickable, IPostTickable, IPostLateTickable, IFixedTickable, IPostFixedTickable | ||
{ | ||
public void Tick() { } | ||
public void FixedTick() { } | ||
public void PostTick() { } | ||
public void PostLateTick() { } | ||
public void PostFixedTick() { } | ||
} | ||
|
||
private class TickableLoopItemTest | ||
{ | ||
[Test] | ||
public void MoveNextWithoutAllocation() | ||
{ | ||
var list = new List<ITickable> { new Ticker(), new Ticker() }; | ||
var exceptionHandler = new EntryPointExceptionHandler(exception => { }); | ||
var tickableLoopItem = new TickableLoopItem(list, exceptionHandler); | ||
|
||
Assert.That(() => | ||
{ | ||
tickableLoopItem.MoveNext(); | ||
}, Is.Not.AllocatingGCMemory()); | ||
} | ||
} | ||
|
||
private class PostTickableLoopItemTest | ||
{ | ||
[Test] | ||
public void MoveNextWithoutAllocation() | ||
{ | ||
var list = new List<IPostTickable> { new Ticker(), new Ticker() }; | ||
var exceptionHandler = new EntryPointExceptionHandler(exception => { }); | ||
var tickableLoopItem = new PostTickableLoopItem(list, exceptionHandler); | ||
|
||
Assert.That(() => | ||
{ | ||
tickableLoopItem.MoveNext(); | ||
}, Is.Not.AllocatingGCMemory()); | ||
} | ||
} | ||
|
||
private class PostLateTickableLoopItemTest | ||
{ | ||
[Test] | ||
public void MoveNextWithoutAllocation() | ||
{ | ||
var list = new List<IPostLateTickable> { new Ticker(), new Ticker() }; | ||
var exceptionHandler = new EntryPointExceptionHandler(exception => { }); | ||
var tickableLoopItem = new PostLateTickableLoopItem(list, exceptionHandler); | ||
|
||
Assert.That(() => | ||
{ | ||
tickableLoopItem.MoveNext(); | ||
}, Is.Not.AllocatingGCMemory()); | ||
} | ||
} | ||
|
||
private class FixedTickableLoopItemTest | ||
{ | ||
[Test] | ||
public void MoveNextWithoutAllocation() | ||
{ | ||
var list = new List<IFixedTickable> { new Ticker(), new Ticker() }; | ||
var exceptionHandler = new EntryPointExceptionHandler(exception => { }); | ||
var tickableLoopItem = new FixedTickableLoopItem(list, exceptionHandler); | ||
|
||
Assert.That(() => | ||
{ | ||
tickableLoopItem.MoveNext(); | ||
}, Is.Not.AllocatingGCMemory()); | ||
} | ||
} | ||
|
||
private class PostFixedTickableLoopItemTest | ||
{ | ||
[Test] | ||
public void MoveNextWithoutAllocation() | ||
{ | ||
var list = new List<IPostFixedTickable> { new Ticker(), new Ticker() }; | ||
var exceptionHandler = new EntryPointExceptionHandler(exception => { }); | ||
var tickableLoopItem = new PostFixedTickableLoopItem(list, exceptionHandler); | ||
|
||
Assert.That(() => | ||
{ | ||
tickableLoopItem.MoveNext(); | ||
}, Is.Not.AllocatingGCMemory()); | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
VContainer/Assets/VContainer/Tests/Unity/PlayerLoopItemTest.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
36089e6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: