Update Project

This commit is contained in:
2026-03-20 13:04:43 +02:00
parent 9b587e6cba
commit beae2dea89
2295 changed files with 251259 additions and 33 deletions
@@ -0,0 +1,281 @@
using System.Collections;
using ModestTree;
using UnityEngine;
using UnityEngine.TestTools;
using Zenject.Tests.Bindings.FromSubContainerPrefab;
#pragma warning disable 649
namespace Zenject.Tests.Bindings
{
public class TestFromSubContainerPrefab : ZenjectIntegrationTestFixture
{
GameObject FooPrefab
{
get { return FixtureUtil.GetPrefab("TestFromSubContainerPrefab/Foo"); }
}
GameObject CircFooPrefab
{
get { return FixtureUtil.GetPrefab("TestFromSubContainerPrefab/CircFoo"); }
}
GameObject FooPrefab2
{
get { return FixtureUtil.GetPrefab("TestFromSubContainerPrefab/Foo2"); }
}
void CommonInstall()
{
Container.Settings = new ZenjectSettings(ValidationErrorResponses.Throw);
}
[UnityTest]
public IEnumerator TestSelfSingle()
{
PreInstall();
CommonInstall();
Container.Bind<Foo>().FromSubContainerResolve()
.ByNewContextPrefab(FooPrefab).AsSingle().NonLazy();
PostInstall();
FixtureUtil.AssertNumGameObjects(1);
FixtureUtil.AssertComponentCount<Foo>(1);
yield break;
}
[UnityTest]
[ValidateOnly]
public IEnumerator TestSelfSingleValidate()
{
PreInstall();
CommonInstall();
Container.Bind<Foo>().FromSubContainerResolve()
.ByNewContextPrefab(FooPrefab).AsSingle().NonLazy();
PostInstall();
yield break;
}
[UnityTest]
[ValidateOnly]
public IEnumerator TestSelfSingleValidateFails()
{
PreInstall();
CommonInstall();
Container.Bind<Foo>().FromSubContainerResolve()
.ByNewContextPrefab(FooPrefab2).AsSingle().NonLazy();
Assert.Throws(() => PostInstall());
yield break;
}
[UnityTest]
public IEnumerator TestSelfTransient()
{
PreInstall();
CommonInstall();
Container.Bind<Foo>().FromSubContainerResolve().ByNewContextPrefab(FooPrefab).AsTransient().NonLazy();
PostInstall();
FixtureUtil.AssertNumGameObjects(1);
FixtureUtil.AssertComponentCount<Foo>(1);
yield break;
}
[UnityTest]
public IEnumerator TestSelfCached()
{
PreInstall();
CommonInstall();
Container.Bind<Foo>().FromSubContainerResolve().ByNewContextPrefab(FooPrefab).AsSingle().NonLazy();
PostInstall();
FixtureUtil.AssertNumGameObjects(1);
FixtureUtil.AssertComponentCount<Foo>(1);
yield break;
}
[UnityTest]
public IEnumerator TestSelfSingleMultipleContracts()
{
PreInstall();
CommonInstall();
Container.Bind(typeof(Foo), typeof(Bar)).FromSubContainerResolve().ByNewContextPrefab(FooPrefab).AsSingle().NonLazy();
PostInstall();
FixtureUtil.AssertNumGameObjects(1);
FixtureUtil.AssertComponentCount<Foo>(1);
FixtureUtil.AssertComponentCount<Bar>(1);
yield break;
}
[UnityTest]
public IEnumerator TestSelfCachedMultipleContracts()
{
PreInstall();
CommonInstall();
Container.Bind(typeof(Foo), typeof(Bar)).FromSubContainerResolve().ByNewContextPrefab(FooPrefab).AsSingle().NonLazy();
PostInstall();
FixtureUtil.AssertNumGameObjects(1);
FixtureUtil.AssertComponentCount<Foo>(1);
FixtureUtil.AssertComponentCount<Bar>(1);
yield break;
}
[UnityTest]
public IEnumerator TestSelfTransientMultipleContracts()
{
PreInstall();
CommonInstall();
Container.Bind(typeof(Foo), typeof(Bar)).FromSubContainerResolve().ByNewContextPrefab(FooPrefab).AsTransient().NonLazy();
PostInstall();
FixtureUtil.AssertNumGameObjects(2);
FixtureUtil.AssertComponentCount<Foo>(2);
FixtureUtil.AssertComponentCount<Bar>(2);
yield break;
}
[UnityTest]
public IEnumerator TestConcreteSingle()
{
PreInstall();
CommonInstall();
Container.Bind<IFoo>().To<Foo>().FromSubContainerResolve().ByNewContextPrefab(FooPrefab).AsSingle().NonLazy();
PostInstall();
FixtureUtil.AssertNumGameObjects(1);
FixtureUtil.AssertComponentCount<Foo>(1);
yield break;
}
[UnityTest]
public IEnumerator TestConcreteTransient()
{
PreInstall();
CommonInstall();
Container.Bind<IFoo>().To<Foo>().FromSubContainerResolve()
.ByNewContextPrefab(FooPrefab).AsTransient().NonLazy();
PostInstall();
FixtureUtil.AssertNumGameObjects(1);
FixtureUtil.AssertComponentCount<Foo>(1);
yield break;
}
[UnityTest]
public IEnumerator TestConcreteCached()
{
PreInstall();
CommonInstall();
Container.Bind<IFoo>().To<Foo>().FromSubContainerResolve().ByNewContextPrefab(FooPrefab).AsSingle().NonLazy();
PostInstall();
FixtureUtil.AssertNumGameObjects(1);
FixtureUtil.AssertComponentCount<Foo>(1);
yield break;
}
[UnityTest]
public IEnumerator TestConcreteSingleMultipleContracts()
{
PreInstall();
CommonInstall();
Container.Bind(typeof(Bar), typeof(IFoo)).To(typeof(Foo), typeof(Bar))
.FromSubContainerResolve().ByNewContextPrefab(FooPrefab).AsSingle().NonLazy();
PostInstall();
FixtureUtil.AssertNumGameObjects(1);
FixtureUtil.AssertComponentCount<Foo>(1);
FixtureUtil.AssertComponentCount<Bar>(1);
yield break;
}
[UnityTest]
public IEnumerator TestConcreteCachedMultipleContracts()
{
PreInstall();
CommonInstall();
Container.Bind(typeof(Foo), typeof(IFoo)).To<Foo>().FromSubContainerResolve().ByNewContextPrefab(FooPrefab).AsSingle().NonLazy();
PostInstall();
FixtureUtil.AssertNumGameObjects(1);
FixtureUtil.AssertComponentCount<Foo>(1);
yield break;
}
[UnityTest]
public IEnumerator TestSelfIdentifiersFails()
{
PreInstall();
CommonInstall();
Container.Bind<Gorp>().FromSubContainerResolve().ByNewContextPrefab(FooPrefab).AsSingle().NonLazy();
Assert.Throws(() => PostInstall());
yield break;
}
[UnityTest]
public IEnumerator TestSelfIdentifiers()
{
PreInstall();
CommonInstall();
Container.Settings = new ZenjectSettings(ValidationErrorResponses.Throw);
Container.Bind<Gorp>().FromSubContainerResolve("gorp").ByNewContextPrefab(FooPrefab).AsSingle().NonLazy();
PostInstall();
FixtureUtil.AssertNumGameObjects(1);
yield break;
}
[UnityTest]
public IEnumerator TestCircularDependency()
{
PreInstall();
CommonInstall();
Container.Bind<CircBar>().FromNewComponentOnNewGameObject().AsSingle();
Container.Bind<CircFoo>().FromSubContainerResolve()
.ByNewContextPrefab(CircFooPrefab).AsSingle().NonLazy();
PostInstall();
FixtureUtil.AssertNumGameObjects(2);
FixtureUtil.AssertComponentCount<CircFoo>(1);
FixtureUtil.AssertComponentCount<CircBar>(1);
yield break;
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bdaee535959c3024c889b3b486fa661a
timeCreated: 1476626071
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: