Skip to content

Commit

Permalink
Fix a test that sometimes fail
Browse files Browse the repository at this point in the history
  • Loading branch information
hadashiA committed May 3, 2021
1 parent 26ea57a commit fcf65d3
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions VContainer/Assets/VContainer/Tests/Unity/EntryPointTest.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Collections;
using NUnit.Framework;
using UnityEngine;
using UnityEngine.TestTools;
using VContainer.Unity;

Expand All @@ -16,8 +17,6 @@ public IEnumerator Create()
builder.Register<DisposableServiceA>(Lifetime.Scoped);
});

yield return null;
yield return null;
yield return null;

var entryPoint = lifetimeScope.Container.Resolve<SampleEntryPoint>();
Expand All @@ -28,6 +27,11 @@ public IEnumerator Create()
Assert.That(entryPoint.StartCalled, Is.EqualTo(1));
Assert.That(entryPoint.PostStartCalled, Is.EqualTo(1));

yield return new WaitForFixedUpdate();

Assert.That(entryPoint.FixedTickCalls, Is.GreaterThan(0));
Assert.That(entryPoint.PostFixedTickCalls, Is.GreaterThan(0));

var fixedTickCalls = entryPoint.FixedTickCalls;
var postFixedTickCalls = entryPoint.PostFixedTickCalls;
var tickCalls = entryPoint.TickCalls;
Expand All @@ -38,23 +42,16 @@ public IEnumerator Create()
var disposable = lifetimeScope.Container.Resolve<DisposableServiceA>();
lifetimeScope.Dispose();

Assert.That(fixedTickCalls, Is.GreaterThan(0));
Assert.That(postFixedTickCalls, Is.GreaterThan(0));
Assert.That(tickCalls, Is.GreaterThan(1));
Assert.That(postTickCalls, Is.GreaterThan(1));
Assert.That(lateTickCalls, Is.GreaterThan(1));
Assert.That(postLateTickCalls, Is.GreaterThan(1));

yield return null;
yield return null;
yield return new WaitForFixedUpdate();

Assert.That(fixedTickCalls, Is.EqualTo(fixedTickCalls));
Assert.That(postFixedTickCalls, Is.EqualTo(postFixedTickCalls));
Assert.That(tickCalls, Is.EqualTo(tickCalls));
Assert.That(postTickCalls, Is.EqualTo(postTickCalls));
Assert.That(lateTickCalls, Is.EqualTo(lateTickCalls));
Assert.That(postLateTickCalls, Is.EqualTo(postLateTickCalls));
Assert.That(disposable.Disposed, Is.True);
Assert.That(entryPoint.FixedTickCalls, Is.EqualTo(fixedTickCalls));
Assert.That(entryPoint.PostFixedTickCalls, Is.EqualTo(postFixedTickCalls));
Assert.That(entryPoint.TickCalls, Is.EqualTo(tickCalls));
Assert.That(entryPoint.PostTickCalls, Is.EqualTo(postTickCalls));
Assert.That(entryPoint.LateTickCalls, Is.EqualTo(lateTickCalls));
Assert.That(entryPoint.PostLateTickCalls, Is.EqualTo(postLateTickCalls));
}

[UnityTest]
Expand Down

0 comments on commit fcf65d3

Please sign in to comment.