-
Notifications
You must be signed in to change notification settings - Fork 362
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
118bbec
commit f99e188
Showing
19 changed files
with
241 additions
and
41 deletions.
There are no files selected for viewing
104 changes: 104 additions & 0 deletions
104
...Project/Assets/Zenject/OptionalExtras/UnitTests/Editor/Factories/IFactory/TestIFactory.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Zenject; | ||
using NUnit.Framework; | ||
using System.Linq; | ||
using ModestTree; | ||
using Assert=ModestTree.Assert; | ||
|
||
namespace Zenject.Tests.Bindings | ||
{ | ||
[TestFixture] | ||
public class TestIFactory : TestWithContainer | ||
{ | ||
[Test] | ||
public void Test1() | ||
{ | ||
Container.BindIFactory<Foo>(); | ||
|
||
var factory = Container.Resolve<IFactory<Foo>>(); | ||
|
||
Assert.IsNotNull(factory.Create()); | ||
} | ||
|
||
[Test] | ||
public void Test2Error() | ||
{ | ||
Container.BindIFactory<FooTwo>(); | ||
|
||
Assert.Throws(() => Container.Validate()); | ||
|
||
var factory = Container.Resolve<IFactory<FooTwo>>(); | ||
|
||
Assert.Throws(() => factory.Create()); | ||
} | ||
|
||
[Test] | ||
public void Test2() | ||
{ | ||
Container.BindIFactory<string, FooTwo>(); | ||
|
||
Container.Validate(); | ||
|
||
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>(); | ||
|
||
Container.Validate(); | ||
|
||
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; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
12 changes: 12 additions & 0 deletions
12
...ct/Assets/Zenject/OptionalExtras/UnitTests/Editor/Factories/IFactory/TestIFactory.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.