Initial Commit
This commit is contained in:
+128
@@ -0,0 +1,128 @@
|
||||
|
||||
using System.Collections;
|
||||
using ModestTree;
|
||||
using UnityEngine;
|
||||
using UnityEngine.TestTools;
|
||||
|
||||
namespace Zenject.Tests.Bindings.FromPrefabInstaller
|
||||
{
|
||||
public class TestFromPrefabInstaller : ZenjectIntegrationTestFixture
|
||||
{
|
||||
GameObject FooPrefab
|
||||
{
|
||||
get { return FixtureUtil.GetPrefab(FooPrefabResourcePath); }
|
||||
}
|
||||
|
||||
string FooPrefabResourcePath
|
||||
{
|
||||
get { return "TestFromPrefabInstaller/Foo"; }
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator TestInstaller()
|
||||
{
|
||||
PreInstall();
|
||||
|
||||
Container.Bind<Qux>().FromSubContainerResolve()
|
||||
.ByNewPrefabInstaller<FooInstaller>(FooPrefab).AsCached();
|
||||
|
||||
PostInstall();
|
||||
|
||||
Assert.IsEqual(Container.Resolve<Qux>().Data, "asdf");
|
||||
yield break;
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator TestInstallerGetter()
|
||||
{
|
||||
PreInstall();
|
||||
|
||||
Container.Bind<Qux>().FromSubContainerResolve()
|
||||
.ByNewPrefabInstaller<FooInstaller>(_ => FooPrefab).AsCached();
|
||||
|
||||
PostInstall();
|
||||
|
||||
Assert.IsEqual(Container.Resolve<Qux>().Data, "asdf");
|
||||
yield break;
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator TestMethod()
|
||||
{
|
||||
PreInstall();
|
||||
|
||||
Container.Bind<Qux>().FromSubContainerResolve()
|
||||
.ByNewPrefabMethod(FooPrefab, InstallFoo).AsCached();
|
||||
|
||||
PostInstall();
|
||||
|
||||
Assert.IsEqual(Container.Resolve<Qux>().Data, "asdf");
|
||||
yield break;
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator TestMethodGetter()
|
||||
{
|
||||
PreInstall();
|
||||
|
||||
Container.Bind<Qux>().FromSubContainerResolve()
|
||||
.ByNewPrefabMethod((context) => FooPrefab, InstallFoo).AsCached();
|
||||
|
||||
PostInstall();
|
||||
|
||||
Assert.IsEqual(Container.Resolve<Qux>().Data, "asdf");
|
||||
yield break;
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator TestResourceInstaller()
|
||||
{
|
||||
PreInstall();
|
||||
|
||||
Container.Bind<Qux>().FromSubContainerResolve()
|
||||
.ByNewPrefabResourceInstaller<FooInstaller>(FooPrefabResourcePath).AsCached();
|
||||
|
||||
PostInstall();
|
||||
|
||||
Assert.IsEqual(Container.Resolve<Qux>().Data, "asdf");
|
||||
yield break;
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator TestResourceMethod()
|
||||
{
|
||||
PreInstall();
|
||||
|
||||
Container.Bind<Qux>().FromSubContainerResolve()
|
||||
.ByNewPrefabResourceMethod(FooPrefabResourcePath, InstallFoo).AsCached();
|
||||
|
||||
PostInstall();
|
||||
|
||||
Assert.IsEqual(Container.Resolve<Qux>().Data, "asdf");
|
||||
yield break;
|
||||
}
|
||||
|
||||
void InstallFoo(DiContainer subContainer)
|
||||
{
|
||||
subContainer.Bind<Qux>().AsSingle().WithArguments("asdf");
|
||||
}
|
||||
|
||||
public class Qux
|
||||
{
|
||||
[Inject]
|
||||
public string Data;
|
||||
|
||||
[Inject]
|
||||
public Foo Foo;
|
||||
}
|
||||
|
||||
public class FooInstaller : Installer<FooInstaller>
|
||||
{
|
||||
public override void InstallBindings()
|
||||
{
|
||||
Container.Bind<Qux>().AsSingle().WithArguments("asdf");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6591427867291174ba958928b193a190
|
||||
timeCreated: 1528215846
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user