Example #1
0
        public virtual void SetUp()
        {
            _hasStarted   = false;
            _isValidating = CurrentTestHasAttribute <ValidateOnlyAttribute>();

            ProjectContext.ValidateOnNextRun = _isValidating;

            _sceneContext = new GameObject("SceneContext").AddComponent <SceneContext>();
            _sceneContext.ParentNewObjectsUnderRoot = true;
            // This creates the container but does not resolve the roots yet
            _sceneContext.Install();
        }
        public virtual void SetUp()
        {
            // Don't clear the scene to allow tests to initialize the scene how they
            // want to set it up manually in their own [Setup] method (eg. TestFromComponentInChildren)
            // Also, I think unity might already clear the scene anyway?
            //ClearScene();

            _hasStarted   = false;
            _isValidating = CurrentTestHasAttribute <ValidateOnlyAttribute>();

            ProjectContext.ValidateOnNextRun = _isValidating;

            _sceneContext = new GameObject("SceneContext").AddComponent <SceneContext>();
            _sceneContext.ParentNewObjectsUnderRoot = true;
            // This creates the container but does not resolve the roots yet
            _sceneContext.Install();
        }
Example #3
0
        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);
        }