using System.Collections; using System.Linq; using NUnit.Framework; using UnityEngine; using UnityEngine.TestTools; using Assert = ModestTree.Assert; namespace Zenject.Tests.Bindings.FromComponentInHierarchyGameObjectContext { public class TestFromComponentInHierarchyGameObjectContext : ZenjectIntegrationTestFixture { GameObject FooPrefab { get { return FixtureUtil.GetPrefab("TestFromComponentInHierarchyGameObjectContext/Foo"); } } [SetUp] public void SetUp() { new GameObject().AddComponent(); new GameObject().AddComponent(); } [UnityTest] public IEnumerator TestCorrectHierarchy() { PreInstall(); Container.Bind().FromSubContainerResolve() .ByNewContextPrefab(FooPrefab).AsSingle().NonLazy(); PostInstall(); var foo = Container.Resolve(); Assert.IsNotNull(foo.Gorp); Assert.IsEqual(foo.gameObject.GetComponentsInChildren().Single(), foo.Gorp); yield break; } } }