-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SceneEntryPointLifecycleSequenceRecorder
- Loading branch information
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
57 changes: 57 additions & 0 deletions
57
...oft.Navigathena/Tests/Runtime/SceneManagement/SceneEntryPointLifecycleSequenceRecorder.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,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace MackySoft.Navigathena.SceneManagement.Tests | ||
{ | ||
public sealed class SceneEntryPointLifecycleSequenceRecorder | ||
{ | ||
|
||
readonly List<(ISceneIdentifier identifier, SceneEntryPointCallbackFlags flags)> m_Sequence = new(); | ||
|
||
public void Assert (params (ISceneIdentifier identifier, SceneEntryPointCallbackFlags flags)[] expectedSequence) | ||
{ | ||
if (m_Sequence.Count != expectedSequence.Length) | ||
{ | ||
throw new Exception($"Expected sequence length is {expectedSequence.Length} but actual is {m_Sequence.Count}."); | ||
} | ||
|
||
for (int i = 0; i < m_Sequence.Count; i++) | ||
{ | ||
var actual = m_Sequence[i]; | ||
var expected = expectedSequence[i]; | ||
|
||
if (actual.identifier != expected.identifier) | ||
{ | ||
throw new Exception($"Expected identifier is {expected.identifier} but actual is {actual.identifier}."); | ||
} | ||
|
||
if (actual.flags != expected.flags) | ||
{ | ||
throw new Exception($"Expected flags is {expected.flags} but actual is {actual.flags}."); | ||
} | ||
} | ||
} | ||
|
||
public ISceneEntryPointLifecycleListener With (ISceneIdentifier identifier) | ||
{ | ||
return new Listener(this,identifier); | ||
} | ||
|
||
sealed class Listener : ISceneEntryPointLifecycleListener | ||
{ | ||
readonly SceneEntryPointLifecycleSequenceRecorder m_Assert; | ||
readonly ISceneIdentifier m_Identifier; | ||
|
||
public Listener (SceneEntryPointLifecycleSequenceRecorder assert, ISceneIdentifier identifier) | ||
{ | ||
m_Assert = assert; | ||
m_Identifier = identifier; | ||
} | ||
|
||
void ISceneEntryPointLifecycleListener.OnReceive (SceneEntryPointCallbackFlags flags) | ||
{ | ||
m_Assert.m_Sequence.Add((m_Identifier,flags)); | ||
} | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...avigathena/Tests/Runtime/SceneManagement/SceneEntryPointLifecycleSequenceRecorder.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.