ssannandeji / Zenject-2019

Dependency Injection Framework for Unity3D
MIT License
2.53k stars 363 forks source link

ZenjectIntegrationTestFixture, line 70, Assert.IsNull(_sceneContext) assertion fail #597

Closed Maesla closed 5 years ago

Maesla commented 5 years ago

In ZenjectIntegrationTestFixture, Assert.IsNull(_sceneContext) assert fail, altought _sceneContext is null.

Reproduction, launch two consecutive integration test that load a scene. The first test creates a _sceneContext The second test destroys the first _sceneContext, but _sceneContext is not null, it is "fake null" instead.

Why is this? because _sceneContext is a monobehaviour and it has its own null state, but Assert.IsNull doesn't understand this.

Fix suggestion: //Assert.IsNull(_sceneContext); Assert.That(_sceneContext == null);

== operator is overloaded in Unity to take this into account.

Additional info: https://blogs.unity3d.com/es/2014/05/16/custom-operator-should-we-keep-it/ Regards.

svermeulen commented 5 years ago

I couldn't reproduce the error but your suggested fix makes sense so I added it. Thanks!