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,9 @@
fileFormatVersion: 2
guid: 5e3c408f00aae61468d936ac29f004d1
folderAsset: yes
timeCreated: 1461708047
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,84 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFrom0 : ZenjectUnitTestFixture
{
[Test]
public void TestSelf1()
{
Container.BindFactory<Foo, Foo.Factory>().NonLazy();
Assert.IsNotNull(Container.Resolve<Foo.Factory>().Create());
}
[Test]
public void TestSelf2()
{
Container.BindFactory<Foo, Foo.Factory>().NonLazy();
Assert.IsNotNull(Container.Resolve<Foo.Factory>().Create());
}
[Test]
public void TestSelf3()
{
Container.BindFactory<Foo, Foo.Factory>().FromNew().NonLazy();
Assert.IsNotNull(Container.Resolve<Foo.Factory>().Create());
}
[Test]
public void TestFactoryScopeDefault()
{
Container.BindFactory<Foo, Foo.Factory>();
Assert.IsEqual(Container.Resolve<Foo.Factory>(), Container.Resolve<Foo.Factory>());
}
[Test]
public void TestFactoryScopeTransient()
{
Container.BindFactory<Foo, Foo.Factory>().AsTransient();
Assert.IsNotEqual(Container.Resolve<Foo.Factory>(), Container.Resolve<Foo.Factory>());
}
[Test]
public void TestConcrete()
{
Container.BindFactory<IFoo, IFooFactory>().To<Foo>().NonLazy();
Assert.IsNotNull(Container.Resolve<IFooFactory>().Create());
Assert.That(Container.Resolve<IFooFactory>().Create() is Foo);
}
[Test]
public void TestConcreteUntyped()
{
Container.BindFactory<IFoo, IFooFactory>().To(typeof(Foo)).NonLazy();
Assert.IsNotNull(Container.Resolve<IFooFactory>().Create());
Assert.That(Container.Resolve<IFooFactory>().Create() is Foo);
}
interface IFoo
{
}
class IFooFactory : PlaceholderFactory<IFoo>
{
}
class Foo : IFoo
{
public class Factory : PlaceholderFactory<Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: cd589059f4c2ff341a25698a4a1673d9
timeCreated: 1485738788
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,55 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFrom1 : ZenjectUnitTestFixture
{
[Test]
public void TestSelf()
{
Container.BindFactory<string, Foo, Foo.Factory>().NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create("asdf").Value, "asdf");
}
[Test]
public void TestConcrete()
{
Container.BindFactory<string, IFoo, IFooFactory>().To<Foo>().NonLazy();
var ifoo = Container.Resolve<IFooFactory>().Create("asdf");
Assert.IsNotNull(ifoo);
Assert.IsEqual(((Foo)ifoo).Value, "asdf");
}
interface IFoo
{
}
class IFooFactory : PlaceholderFactory<string, IFoo>
{
}
class Foo : IFoo
{
public Foo(string value)
{
Value = value;
}
public string Value
{
get;
private set;
}
public class Factory : PlaceholderFactory<string, Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2aeb922683e72ac4f9fd3806715e65df
timeCreated: 1485738782
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,64 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFrom5 : ZenjectUnitTestFixture
{
[Test]
public void TestSelf1()
{
Container.BindFactory<string, int, string, float, int, Foo, Foo.Factory>().NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create("asdf", 2, "a", 4.2f, 6).P1, "asdf");
}
[Test]
public void TestSelf2()
{
Container.BindFactory<string, int, string, float, int, Foo, Foo.Factory>().NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create("asdf", 2, "a", 4.2f, 6).P1, "asdf");
}
[Test]
public void TestConcrete()
{
Container.BindFactory<string, int, string, float, int, IFoo, IFooFactory>().To<Foo>().NonLazy();
var ifoo = Container.Resolve<IFooFactory>().Create("asdf", 2, "a", 4.2f, 6);
Assert.IsNotNull(ifoo);
Assert.IsEqual(((Foo)ifoo).P1, "asdf");
}
interface IFoo
{
}
class IFooFactory : PlaceholderFactory<string, int, string, float, int, IFoo>
{
}
class Foo : IFoo
{
public Foo(string p1, int p2, string p3, float p4, int p5)
{
P1 = p1;
}
public string P1
{
get;
private set;
}
public class Factory : PlaceholderFactory<string, int, string, float, int, Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: db247dfbb1d6d284cae35a8f3ae55f17
timeCreated: 1485738788
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,75 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFromFactory0 : ZenjectUnitTestFixture
{
static Foo StaticFoo = new Foo();
[Test]
public void TestSelf()
{
Container.BindFactory<Foo, Foo.Factory>().FromIFactory(b => b.To<CustomFooFactory>().AsCached()).NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create(), StaticFoo);
}
[Test]
public void TestConcrete()
{
Container.BindFactory<IFoo, IFooFactory>()
.To<Foo>().FromIFactory(b => b.To<CustomFooFactory>().AsCached()).NonLazy();
Assert.IsEqual(Container.Resolve<IFooFactory>().Create(), StaticFoo);
}
[Test]
public void TestFactoryValidation()
{
Container.BindFactory<IFoo, IFooFactory>()
.To<Foo>().FromIFactory(b => b.To<CustomFooFactoryWithValidate>().AsCached()).NonLazy();
Container.Resolve<IFooFactory>().Create();
}
class CustomFooFactoryWithValidate : IFactory<Foo>, IValidatable
{
public Foo Create()
{
return StaticFoo;
}
public void Validate()
{
throw Assert.CreateException("Test error");
}
}
class CustomFooFactory : IFactory<Foo>
{
public Foo Create()
{
return StaticFoo;
}
}
interface IFoo
{
}
class IFooFactory : PlaceholderFactory<IFoo>
{
}
class Foo : IFoo
{
public class Factory : PlaceholderFactory<Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1ccf6a6010280bd4c80cd60ddfc3251c
timeCreated: 1485738782
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,64 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFromFactory1 : ZenjectUnitTestFixture
{
[Test]
public void TestSelf()
{
Container.BindFactory<string, Foo, Foo.Factory>().FromIFactory(b => b.To<CustomFooFactory>().AsCached()).NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create("asdf").Value, "asdf");
}
[Test]
public void TestConcrete()
{
Container.BindFactory<string, IFoo, IFooFactory>().To<Foo>().FromIFactory(b => b.To<CustomFooFactory>().AsCached()).NonLazy();
Assert.IsEqual(Container.Resolve<IFooFactory>().Create("asdf").Value, "asdf");
}
class CustomFooFactory : IFactory<string, Foo>
{
public Foo Create(string value)
{
return new Foo(value);
}
}
interface IFoo
{
string Value
{
get;
}
}
class IFooFactory : PlaceholderFactory<string, IFoo>
{
}
class Foo : IFoo
{
public Foo(string value)
{
Value = value;
}
public string Value
{
get;
private set;
}
public class Factory : PlaceholderFactory<string, Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ba619dabc8cdb2a4b853e8d7d88b9a23
timeCreated: 1485738787
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,41 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFromGetter0 : ZenjectUnitTestFixture
{
[Test]
public void TestSelf()
{
Container.Bind<Foo>().AsSingle().NonLazy();
Container.BindFactory<Bar, Bar.Factory>().FromResolveGetter<Foo>(x => x.Bar).NonLazy();
Assert.IsNotNull(Container.Resolve<Bar.Factory>().Create());
Assert.IsEqual(Container.Resolve<Bar.Factory>().Create(), Container.Resolve<Foo>().Bar);
}
class Bar
{
public class Factory : PlaceholderFactory<Bar>
{
}
}
class Foo
{
public Foo()
{
Bar = new Bar();
}
public Bar Bar
{
get;
private set;
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 02801e9ad7fdcd54990732b0e9ec2d0f
timeCreated: 1485738780
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,45 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFromInstance0 : ZenjectUnitTestFixture
{
[Test]
public void TestSelf()
{
var foo = new Foo();
Container.BindFactory<Foo, Foo.Factory>().FromInstance(foo).NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create(), foo);
}
[Test]
public void TestConcrete()
{
var foo = new Foo();
Container.BindFactory<IFoo, IFooFactory>().FromInstance(foo).NonLazy();
Assert.IsEqual(Container.Resolve<IFooFactory>().Create(), foo);
}
interface IFoo
{
}
class IFooFactory : PlaceholderFactory<IFoo>
{
}
class Foo : IFoo
{
public class Factory : PlaceholderFactory<Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a07aa9c58bcc5094f8e29f0d10303fb8
timeCreated: 1485738786
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,45 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFromMethod0 : ZenjectUnitTestFixture
{
[Test]
public void TestSelf()
{
var foo = new Foo();
Container.BindFactory<Foo, Foo.Factory>().FromMethod(c => foo).NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create(), foo);
}
[Test]
public void TestConcrete()
{
var foo = new Foo();
Container.BindFactory<IFoo, IFooFactory>().FromMethod(c => foo).NonLazy();
Assert.IsEqual(Container.Resolve<IFooFactory>().Create(), foo);
}
interface IFoo
{
}
class IFooFactory : PlaceholderFactory<IFoo>
{
}
class Foo : IFoo
{
public class Factory : PlaceholderFactory<Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8cac25659efcbbb47ab2876811408f52
timeCreated: 1485738785
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,58 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFromMethod1 : ZenjectUnitTestFixture
{
[Test]
public void TestSelf()
{
Container.BindFactory<string, Foo, Foo.Factory>().FromMethod((c, value) => new Foo(value)).NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create("asdf").Value, "asdf");
}
[Test]
public void TestConcrete()
{
Container.BindFactory<string, IFoo, IFooFactory>().FromMethod((c, value) => new Foo(value)).NonLazy();
Assert.IsEqual(Container.Resolve<IFooFactory>().Create("asdf").Value, "asdf");
}
interface IFoo
{
string Value
{
get;
}
}
class IFooFactory : PlaceholderFactory<string, IFoo>
{
}
class Foo : IFoo
{
public Foo(string value)
{
Value = value;
}
public string Value
{
get;
private set;
}
public class Factory : PlaceholderFactory<string, Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 75b2bb6fc90254044b1eae12b63cafb3
timeCreated: 1485738784
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,72 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFromResolve0 : ZenjectUnitTestFixture
{
[Test]
public void TestSelf()
{
var foo = new Foo();
Container.BindInstance(foo).NonLazy();
Container.BindFactory<Foo, Foo.Factory>().FromResolve().NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create(), foo);
}
[Test]
public void TestConcrete()
{
var foo = new Foo();
Container.BindInstance(foo).NonLazy();
Container.BindFactory<IFoo, IFooFactory>().To<Foo>().FromResolve().NonLazy();
Assert.IsEqual(Container.Resolve<IFooFactory>().Create(), foo);
}
[Test]
public void TestSelfIdentifier()
{
var foo = new Foo();
Container.BindInstance(foo).WithId("foo").NonLazy();
Container.BindFactory<Foo, Foo.Factory>().FromResolve("foo").NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create(), foo);
}
[Test]
public void TestConcreteIdentifier()
{
var foo = new Foo();
Container.BindInstance(foo).WithId("foo").NonLazy();
Container.BindFactory<IFoo, IFooFactory>().To<Foo>().FromResolve("foo").NonLazy();
Assert.IsEqual(Container.Resolve<IFooFactory>().Create(), foo);
}
interface IFoo
{
}
class IFooFactory : PlaceholderFactory<IFoo>
{
}
class Foo : IFoo
{
public class Factory : PlaceholderFactory<Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bde11a0eb028e1a4d9f8cd47b9752dad
timeCreated: 1485738787
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,55 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFromSubContainerInstaller0 : ZenjectUnitTestFixture
{
[Test]
public void TestSelf()
{
Container.BindFactory<Foo, Foo.Factory>()
.FromSubContainerResolve().ByInstaller<FooInstaller>().NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create(), FooInstaller.Foo);
}
[Test]
public void TestConcrete()
{
Container.BindFactory<IFoo, IFooFactory>()
.To<Foo>().FromSubContainerResolve().ByInstaller<FooInstaller>().NonLazy();
Assert.IsEqual(Container.Resolve<IFooFactory>().Create(), FooInstaller.Foo);
}
class FooInstaller : Installer<FooInstaller>
{
public static Foo Foo = new Foo();
public override void InstallBindings()
{
Container.Bind<Foo>().FromInstance(Foo);
}
}
interface IFoo
{
}
class IFooFactory : PlaceholderFactory<IFoo>
{
}
class Foo : IFoo
{
public class Factory : PlaceholderFactory<Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: a75a7d0a0d0a978459537926595a8f75
timeCreated: 1485738786
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,75 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFromSubContainerInstaller1 : ZenjectUnitTestFixture
{
[Test]
public void TestSelf()
{
Container.BindFactory<string, Foo, Foo.Factory>()
.FromSubContainerResolve().ByInstaller<FooInstaller>().NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create("asdf").Value, "asdf");
}
[Test]
public void TestConcrete()
{
Container.BindFactory<string, IFoo, IFooFactory>()
.To<Foo>().FromSubContainerResolve().ByInstaller<FooInstaller>().NonLazy();
Assert.IsEqual(Container.Resolve<IFooFactory>().Create("asdf").Value, "asdf");
}
class FooInstaller : Installer<string, FooInstaller>
{
readonly string _value;
public FooInstaller(string value)
{
_value = value;
}
public override void InstallBindings()
{
Container.Bind<Foo>().AsTransient().WithArgumentsExplicit(
InjectUtil.CreateArgListExplicit(_value));
}
}
interface IFoo
{
string Value
{
get;
}
}
class IFooFactory : PlaceholderFactory<string, IFoo>
{
}
class Foo : IFoo
{
public Foo(string value)
{
Value = value;
}
public string Value
{
get;
private set;
}
public class Factory : PlaceholderFactory<string, Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 0f5f5adb036584147968b4cf0e1b75a6
timeCreated: 1485738781
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,50 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFromSubContainerMethod0 : ZenjectUnitTestFixture
{
static Foo ConstFoo = new Foo();
[Test]
public void TestSelf()
{
Container.BindFactory<Foo, Foo.Factory>().FromSubContainerResolve().ByMethod(InstallFoo).NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create(), ConstFoo);
}
[Test]
public void TestConcrete()
{
Container.BindFactory<IFoo, IFooFactory>()
.To<Foo>().FromSubContainerResolve().ByMethod(InstallFoo).NonLazy();
Assert.IsEqual(Container.Resolve<IFooFactory>().Create(), ConstFoo);
}
void InstallFoo(DiContainer subContainer)
{
subContainer.Bind<Foo>().FromInstance(ConstFoo);
}
interface IFoo
{
}
class IFooFactory : PlaceholderFactory<IFoo>
{
}
class Foo : IFoo
{
public class Factory : PlaceholderFactory<Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 99958e9b2f0eefc429b100aafef684ae
timeCreated: 1485738785
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,66 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryFromSubContainerMethod1 : ZenjectUnitTestFixture
{
[Test]
public void TestSelf()
{
Container.BindFactory<string, Foo, Foo.Factory>()
.FromSubContainerResolve().ByMethod(InstallFoo).NonLazy();
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create("asdf").Value, "asdf");
}
[Test]
public void TestConcrete()
{
Container.BindFactory<string, IFoo, IFooFactory>().To<Foo>().FromSubContainerResolve().ByMethod(InstallFoo).NonLazy();
Assert.IsEqual(Container.Resolve<IFooFactory>().Create("asdf").Value, "asdf");
}
void InstallFoo(DiContainer subContainer, string value)
{
subContainer.Bind<Foo>().AsSingle().WithArgumentsExplicit(
InjectUtil.CreateArgListExplicit(value));
}
interface IFoo
{
string Value
{
get;
}
}
class IFooFactory : PlaceholderFactory<string, IFoo>
{
}
class Foo : IFoo
{
public Foo(string value)
{
Value = value;
}
public string Value
{
get;
private set;
}
public class Factory : PlaceholderFactory<string, Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 326764b6ac92ebd4daa3532846e523c9
timeCreated: 1485738782
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,68 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestFactoryWithArguments : ZenjectUnitTestFixture
{
[Test]
public void TestWithArguments1()
{
Container.BindFactory<Foo, Foo.Factory>().WithArguments("asdf");
Assert.IsEqual(Container.Resolve<Foo.Factory>().Create().Value, "asdf");
}
[Test]
public void TestWithFactoryArguments1()
{
Container.BindFactory<Bar, Bar.Factory>().WithFactoryArguments("asdf");
Assert.IsEqual(Container.Resolve<Bar.Factory>().Create().Value, "asdf");
}
public class Foo
{
public Foo(string value)
{
Value = value;
}
public string Value
{
get; private set;
}
public class Factory : PlaceholderFactory<Foo>
{
}
}
public class Bar
{
public string Value
{
get; private set;
}
public class Factory : PlaceholderFactory<Bar>
{
string _value;
public Factory(string value)
{
_value = value;
}
public override Bar Create()
{
var bar = base.Create();
bar.Value = _value;
return bar;
}
}
}
}
}
@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 267196012b398f842894c8ad3a75aea6
timeCreated: 1520770871
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 0da738c2fd2093f4db191a5593a83638
folderAsset: yes
timeCreated: 1461873578
licenseType: Pro
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,93 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.Bindings
{
[TestFixture]
public class TestIFactory : ZenjectUnitTestFixture
{
[Test]
public void Test1()
{
Container.BindIFactory<Foo>();
var factory = Container.Resolve<IFactory<Foo>>();
Assert.IsNotNull(factory.Create());
}
[Test]
public void Test2Error()
{
Container.BindIFactory<FooTwo>();
var factory = Container.Resolve<IFactory<FooTwo>>();
Assert.Throws(() => factory.Create());
}
[Test]
public void Test2()
{
Container.BindIFactory<string, FooTwo>();
var factory = Container.Resolve<IFactory<string, FooTwo>>();
Assert.IsEqual(factory.Create("asdf").Value, "asdf");
}
[Test]
public void Test5()
{
Container.BindIFactory<string, int, char, long, double, IFooFive>().To<FooFive>();
var factory = Container.Resolve<IFactory<string, int, char, long, double, IFooFive>>();
Assert.IsEqual(factory.Create("asdf", 0, 'z', 2, 3.0).P1, "asdf");
}
public class Foo
{
}
public class FooTwo
{
public FooTwo(string value)
{
Value = value;
}
public string Value
{
get;
private set;
}
}
public interface IFooFive
{
string P1
{
get;
}
}
public class FooFive : IFooFive
{
string _p1;
public FooFive(string p1, int p2, char p3, long p4, double p5)
{
_p1 = p1;
}
public string P1
{
get
{
return _p1;
}
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 1663d737024bdf5438c672cef0d2d577
timeCreated: 1461867513
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,30 @@
using NUnit.Framework;
using Assert = ModestTree.Assert;
namespace Zenject.Tests.AbstractFactory
{
[TestFixture]
public class TestFactory : ZenjectUnitTestFixture
{
[Test]
public void TestToSelf()
{
Container.BindFactory<Foo, Foo.Factory>().NonLazy();
Assert.IsNotNull(Container.Resolve<Foo.Factory>().Create());
}
public interface IFoo
{
}
public class Foo : IFoo
{
public class Factory : PlaceholderFactory<Foo>
{
}
}
}
}
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 24764a4ebdf5bb044ad3cef3184d85b6
timeCreated: 1461708049
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: