public void Setup() { Assert.That(Application.isPlaying, "ZenjectIntegrationTestFixture is meant to be used for play mode tests only. Please ensure your test file '{0}' is outside of the editor folder and try again.", GetType()); ZenjectTestUtil.DestroyEverythingExceptTestRunner(true); StaticContext.Clear(); }
protected IEnumerator DestroyEverything() { Assert.That(_hasStartedInstall, "Called DestroyAll but did not call PreInstall (or SkipInstall) in test '{0}'!", TestContext.CurrentContext.Test.Name); DestroyEverythingInternal(false); // Wait one frame for GC to really destroy everything yield return(null); }
public void TearDown() { if (TestContext.CurrentContext.Result.Outcome == ResultState.Success) { Assert.That(_hasStartedInstall, "PreInstall (or SkipInstall) was not called in test '{0}'!", TestContext.CurrentContext.Test.Name); Assert.That(_hasEndedInstall, "PostInstall was not called in test '{0}'!", TestContext.CurrentContext.Test.Name); } DestroyEverythingInternal(true); _hasStartedInstall = false; _hasEndedInstall = false; }
protected void PostInstall() { Assert.That(_hasStartedInstall, "Called PostInstall but did not call PreInstall in test '{0}'!", TestContext.CurrentContext.Test.Name); Assert.That(!_hasEndedInstall, "Called PostInstall twice in test '{0}'!", TestContext.CurrentContext.Test.Name); _hasEndedInstall = true; _sceneContext.Resolve(); Container.Inject(this); if (!Container.IsValidating) { // We don't have to do this here but it's kind of convenient // We could also remove it and just require that users add a yield after calling // and it would have the same effect Container.Resolve <MonoKernel>().Initialize(); } }
protected void PreInstall() { Assert.That(!_hasStartedInstall, "Called PreInstall twice in test '{0}'!", TestContext.CurrentContext.Test.Name); _hasStartedInstall = true; Assert.That(!ProjectContext.HasInstance); var shouldValidate = CurrentTestHasAttribute <ValidateOnlyAttribute>(); ProjectContext.ValidateOnNextRun = shouldValidate; Assert.IsNull(_sceneContext); _sceneContext = SceneContext.Create(); _sceneContext.Install(); Assert.That(ProjectContext.HasInstance); Assert.IsEqual(shouldValidate, ProjectContext.Instance.Container.IsValidating); Assert.IsEqual(shouldValidate, _sceneContext.Container.IsValidating); }