diff --git a/Build/python/mtm/zen/CreateRelease.py b/Build/python/mtm/zen/CreateRelease.py index a4f2049c0..577dc1d78 100644 --- a/Build/python/mtm/zen/CreateRelease.py +++ b/Build/python/mtm/zen/CreateRelease.py @@ -120,6 +120,10 @@ def _createCSharpPackage(self, includeSample, outputPath): self._sys.deleteDirectory('[ZenTempDir]/OptionalExtras/UnitTests') self._sys.removeFile('[ZenTempDir]/OptionalExtras/UnitTests.meta') + self._zipHelper.createZipFile('[ZenTempDir]/OptionalExtras/IntegrationTests', '[ZenTempDir]/OptionalExtras/IntegrationTests.zip') + self._sys.deleteDirectory('[ZenTempDir]/OptionalExtras/IntegrationTests') + self._sys.removeFile('[ZenTempDir]/OptionalExtras/IntegrationTests.meta') + self._zipHelper.createZipFile('[ZenTempDir]/OptionalExtras/AutoMocking', '[ZenTempDir]/OptionalExtras/AutoMocking.zip') self._sys.deleteDirectory('[ZenTempDir]/OptionalExtras/AutoMocking') self._sys.removeFile('[ZenTempDir]/OptionalExtras/AutoMocking.meta') diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests.meta new file mode 100644 index 000000000..f8a62f6cd --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f8d518813058ccd4c8ce2eb0a99748b5 +folderAsset: yes +timeCreated: 1462057592 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings.meta new file mode 100644 index 000000000..f0036cab7 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 3721bff4b7d518847bbb1d65ba04a06f +folderAsset: yes +timeCreated: 1462057592 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject.meta new file mode 100644 index 000000000..9b7408c0d --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 652b62ec6dbe8894e9208457a375f1b6 +folderAsset: yes +timeCreated: 1459194355 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/BindGameObject.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/BindGameObject.unity new file mode 100644 index 000000000..f959e7e82 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/BindGameObject.unity @@ -0,0 +1,156 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &978433746 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 978433749} + - 114: {fileID: 978433747} + - 114: {fileID: 978433750} + m_Layer: 0 + m_Name: SceneCompositionRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &978433747 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 978433750} + m_MethodName: TestGameObjectConcreteSingle + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!4 &978433749 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &978433750 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b2a4b96e29add784fad9924f51f7fa9b, type: 3} + m_Name: + m_EditorClassIdentifier: + CubePrefab: {fileID: 181248, guid: 16c31656842de3b429a3232daac6826c, type: 2} diff --git a/UnityProject/Assets/Zenject/Source/Usage/Mtm.Zenject-usage.csproj.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/BindGameObject.unity.meta similarity index 63% rename from UnityProject/Assets/Zenject/Source/Usage/Mtm.Zenject-usage.csproj.meta rename to UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/BindGameObject.unity.meta index 7510259ac..5d328b606 100644 --- a/UnityProject/Assets/Zenject/Source/Usage/Mtm.Zenject-usage.csproj.meta +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/BindGameObject.unity.meta @@ -1,6 +1,6 @@ fileFormatVersion: 2 -guid: b424282072f5bef469dc8603115d607e -timeCreated: 1461724877 +guid: c21e951b139b8d24d9f719d7a1045f8b +timeCreated: 1459194367 licenseType: Pro DefaultImporter: userData: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Fixture.cs new file mode 100644 index 000000000..e849752ad --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Fixture.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using ModestTree.UnityUnitTester; +using UnityEngine; + +namespace ModestTree.Tests.Zenject.BindGameObject +{ + public class Fixture : MonoTestFixture + { + public GameObject CubePrefab; + + const string GameObjName = "TestObj"; + + [Test] + public void TestGameObjectSelfSingle1() + { + Container.Bind().FromGameObject().WithGameObjectName(GameObjName).AsSingle(); + + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + } + + [Test] + public void TestGameObjectSelfSingle2() + { + Container.Bind().FromGameObject().WithGameObjectName(GameObjName).AsSingle(); + Container.Bind().FromGameObject().WithGameObjectName(GameObjName).AsSingle(); + Container.Bind("asdf").FromGameObject().WithGameObjectName(GameObjName).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve("asdf"); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + } + + [Test] + [ExpectedException] + [ExpectedValidationException] + public void TestGameObjectSelfSingleConflict() + { + Container.Bind().FromGameObject().WithGameObjectName(GameObjName).AsSingle(); + Container.Bind().FromGameObject().WithGameObjectName("asdf").AsSingle(); + + Container.BindRootResolve(); + } + + [Test] + public void TestGameObjectSelfTransient() + { + Container.Bind().FromGameObject().WithGameObjectName(GameObjName).AsTransient(); + Container.Bind().FromGameObject().WithGameObjectName(GameObjName).AsTransient(); + Container.Bind().FromGameObject().WithGameObjectName("asdf").AsTransient(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 3); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 2); + } + + [Test] + public void TestGameObjectConcreteSingle() + { + Container.Bind().To().FromGameObject().WithGameObjectName(GameObjName).AsSingle(); + + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + } + + [Test] + public void TestPrefabSelfSingle1() + { + Container.Bind().FromPrefab(CubePrefab) + .WithGameObjectName(GameObjName).AsSingle(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + + FixtureUtil.AddInitMethod(Container, (GameObject gameObject) => + { + Assert.IsNotNull(gameObject.GetComponent()); + }); + } + + [Test] + public void TestPrefabConcreteSingle1() + { + Container.Bind().To() + .FromPrefab(CubePrefab).WithGameObjectName(GameObjName).AsSingle(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + + FixtureUtil.AddInitMethod(Container, (UnityEngine.Object obj) => + { + Assert.IsNotNull(((GameObject)obj).GetComponent()); + }); + } + + [Test] + public void TestPrefabResourceSelfSingle1() + { + Container.Bind().FromPrefabResource("BindGameObject/Cube").WithGameObjectName(GameObjName).AsSingle(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + + FixtureUtil.AddInitMethod(Container, (GameObject gameObject) => + { + Assert.IsNotNull(gameObject.GetComponent()); + }); + } + + [Test] + public void TestPrefabResourceConcreteSingle1() + { + Container.Bind().To() + .FromPrefabResource("BindGameObject/Cube").WithGameObjectName(GameObjName).AsSingle(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + + FixtureUtil.AddInitMethod(Container, (UnityEngine.Object obj) => + { + Assert.IsNotNull(((GameObject)obj).GetComponent()); + }); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Fixture.cs.meta new file mode 100644 index 000000000..383ac8f48 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b2a4b96e29add784fad9924f51f7fa9b +timeCreated: 1459194367 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Resources.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Resources.meta new file mode 100644 index 000000000..b43e52afd --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9b75849eaa1ecbb4bbe5b7b32c944224 +folderAsset: yes +timeCreated: 1459212986 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Resources/BindGameObject.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Resources/BindGameObject.meta new file mode 100644 index 000000000..f065379fa --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Resources/BindGameObject.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b0648c2df4fbcca4388759ece4a4ef01 +folderAsset: yes +timeCreated: 1459212995 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Resources/BindGameObject/Cube.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Resources/BindGameObject/Cube.prefab new file mode 100644 index 000000000..6334ed628 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Resources/BindGameObject/Cube.prefab @@ -0,0 +1,88 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &181248 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 496296} + - 33: {fileID: 3312568} + - 65: {fileID: 6582216} + - 23: {fileID: 2356458} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &496296 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 181248} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!23 &2356458 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 181248} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 1 + m_ReflectionProbeUsage: 1 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!33 &3312568 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 181248} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!65 &6582216 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 181248} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 181248} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Resources/BindGameObject/Cube.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Resources/BindGameObject/Cube.prefab.meta new file mode 100644 index 000000000..9530216ca --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/BindGameObject/Resources/BindGameObject/Cube.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 16c31656842de3b429a3232daac6826c +timeCreated: 1459207171 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject.meta new file mode 100644 index 000000000..6f7b131ef --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 19ae9275b4e016a4e86f258a85ed8ee5 +folderAsset: yes +timeCreated: 1458174609 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject/Fixture.cs new file mode 100644 index 000000000..bc11a3e48 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject/Fixture.cs @@ -0,0 +1,143 @@ +using System; +using System.Collections.Generic; +using ModestTree.UnityUnitTester; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToGameObject +{ + public class Fixture : MonoTestFixture + { + const string GameObjName = "TestObj"; + + [Test] + public void TestBasic() + { + Container.Bind().FromGameObject().WithGameObjectName(GameObjName).AsSingle(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestSingle() + { + Container.Bind().FromGameObject().WithGameObjectName(GameObjName).AsSingle(); + Container.Bind().To().FromGameObject().WithGameObjectName(GameObjName).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestTransient() + { + Container.Bind().FromGameObject().WithGameObjectName(GameObjName).AsTransient(); + Container.Bind().To().FromGameObject().WithGameObjectName(GameObjName).AsTransient(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 2); + FixtureUtil.AssertComponentCount(Container, 2); + } + + [Test] + public void TestCached1() + { + Container.Bind().FromGameObject().WithGameObjectName(GameObjName).AsCached(); + Container.Bind().To().FromGameObject().WithGameObjectName(GameObjName).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 2); + FixtureUtil.AssertComponentCount(Container, 2); + } + + [Test] + public void TestCached2() + { + Container.Bind(typeof(Foo), typeof(IFoo)).To().FromGameObject().WithGameObjectName(GameObjName).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestMultipleConcreteTransient1() + { + Container.Bind().To(typeof(Foo), typeof(Bar)).FromGameObject() + .WithGameObjectName(GameObjName); + + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 2); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestMultipleConcreteTransient2() + { + Container.Bind(typeof(IFoo), typeof(IBar)).To(new List() {typeof(Foo), typeof(Bar)}).FromGameObject() + .WithGameObjectName(GameObjName).AsTransient(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 4); + FixtureUtil.AssertComponentCount(Container, 2); + FixtureUtil.AssertComponentCount(Container, 2); + } + + [Test] + public void TestMultipleConcreteCached() + { + Container.Bind(typeof(IFoo), typeof(IBar)).To(new List() {typeof(Foo), typeof(Bar)}).FromGameObject() + .WithGameObjectName(GameObjName).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 2); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestMultipleConcreteSingle() + { + Container.Bind(typeof(IFoo), typeof(IBar)).To(new List() {typeof(Foo), typeof(Bar)}).FromGameObject() + .WithGameObjectName(GameObjName).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 2); + } + + public interface IBar + { + } + + public interface IFoo + { + } + + public class Foo : MonoBehaviour, IFoo, IBar + { + } + + public class Bar : MonoBehaviour, IFoo, IBar + { + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject/Fixture.cs.meta new file mode 100644 index 000000000..cdcbe8ac0 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2deb5ef0bad19eb4985c9211357fd32f +timeCreated: 1454598516 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject/TestToGameObject.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject/TestToGameObject.unity new file mode 100644 index 000000000..62b30f310 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject/TestToGameObject.unity @@ -0,0 +1,155 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &978433746 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 978433749} + - 114: {fileID: 978433747} + - 114: {fileID: 978433748} + m_Layer: 0 + m_Name: Runner + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &978433747 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 978433748} + m_MethodName: TestBasic + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!114 &978433748 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2deb5ef0bad19eb4985c9211357fd32f, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!4 &978433749 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject/TestToGameObject.unity.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject/TestToGameObject.unity.meta new file mode 100644 index 000000000..dec221d53 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToGameObject/TestToGameObject.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cd2786136f279c14db1ca265c065edb7 +timeCreated: 1458174769 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour.meta new file mode 100644 index 000000000..edc393cc1 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 3cd2902cb7414ed4ba89a685c8fd445f +folderAsset: yes +timeCreated: 1458256959 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/Fixture.cs new file mode 100644 index 000000000..dc2a2d7a4 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/Fixture.cs @@ -0,0 +1,135 @@ +using System; +using System.Collections.Generic; +using ModestTree.UnityUnitTester; +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToMonoBehaviour +{ + public class Fixture : MonoTestFixture + { + [Test] + public void TestBasic() + { + var gameObject = Container.CreateEmptyGameObject("Foo"); + + Container.BindInstance("Foo", gameObject); + + Container.Bind().FromComponent(gameObject).AsSingle(); + Container.BindRootResolve(); + + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestTransient() + { + var gameObject = Container.CreateEmptyGameObject("Foo"); + + Container.BindInstance("Foo", gameObject); + + Container.Bind().FromComponent(gameObject).AsTransient(); + Container.Bind().To().FromComponent(gameObject).AsTransient(); + + Container.BindRootResolve(typeof(IFoo), typeof(Foo)); + + FixtureUtil.AssertComponentCount(Container, 2); + } + + [Test] + public void TestSingle() + { + var gameObject = Container.CreateEmptyGameObject("Foo"); + + Container.BindInstance("Foo", gameObject); + + Container.Bind().FromComponent(gameObject).AsSingle(); + Container.Bind().To().FromComponent(gameObject).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestCached1() + { + var gameObject = Container.CreateEmptyGameObject("Foo"); + + Container.BindInstance("Foo", gameObject); + + Container.Bind().FromComponent(gameObject).AsCached(); + Container.Bind().To().FromComponent(gameObject).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + FixtureUtil.AssertComponentCount(Container, 2); + } + + [Test] + public void TestCached2() + { + var gameObject = Container.CreateEmptyGameObject("Foo"); + + Container.BindInstance("Foo", gameObject); + + Container.Bind(typeof(IFoo), typeof(Foo)).To().FromComponent(gameObject).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestCachedMultipleConcrete() + { + var gameObject = Container.CreateEmptyGameObject("Foo"); + + Container.BindInstance("Foo", gameObject); + + Container.Bind(typeof(IFoo), typeof(IBar)) + .To(new List() { typeof(Foo), typeof(Bar) }).FromComponent(gameObject).AsCached(); + + Container.BindRootResolve(typeof(IFoo), typeof(IBar)); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestSingleMultipleConcrete() + { + var gameObject = Container.CreateEmptyGameObject("Foo"); + + Container.BindInstance("Foo", gameObject); + + Container.Bind(typeof(IFoo), typeof(IBar)).To(new List() { typeof(Foo), typeof(Bar) }) + .FromComponent(gameObject).AsSingle(); + Container.Bind().To().FromComponent(gameObject).AsSingle(); + + Container.BindRootResolve(typeof(IFoo), typeof(IFoo2), typeof(IBar)); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + public interface IBar + { + } + + public interface IFoo2 + { + } + + public interface IFoo + { + } + + public class Foo : MonoBehaviour, IFoo, IBar, IFoo2 + { + } + + public class Bar : MonoBehaviour, IFoo, IBar, IFoo2 + { + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/Fixture.cs.meta new file mode 100644 index 000000000..1a1654de6 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 53dc2c7cdc3b8384faa7be16b6f424dd +timeCreated: 1458256992 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/Foo.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/Foo.cs new file mode 100644 index 000000000..f0d0372d6 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/Foo.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToTransientPrefab +{ + public interface IFoo + { + } + + public class Foo : MonoBehaviour, IFoo + { + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/Foo.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/Foo.cs.meta new file mode 100644 index 000000000..dc9cf29a0 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/Foo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 43b55cbcde52e55429c835c47117f770 +timeCreated: 1458256992 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/TestToMonoBehaviour.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/TestToMonoBehaviour.unity new file mode 100644 index 000000000..e35b70dac --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/TestToMonoBehaviour.unity @@ -0,0 +1,155 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &978433746 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 978433749} + - 114: {fileID: 978433747} + - 114: {fileID: 978433750} + m_Layer: 0 + m_Name: SceneCompositionRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &978433747 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 978433750} + m_MethodName: 546573744361636865644d756c7469706c65436f6e6372657465 + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: 556e697479456e67696e652e4f626a6563742c20556e697479456e67696e65 + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!4 &978433749 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &978433750 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 53dc2c7cdc3b8384faa7be16b6f424dd, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/TestToMonoBehaviour.unity.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/TestToMonoBehaviour.unity.meta new file mode 100644 index 000000000..e59b241aa --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToMonoBehaviour/TestToMonoBehaviour.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 07b92e39b79a9684da04dfdc3511340d +timeCreated: 1458256992 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab.meta new file mode 100644 index 000000000..14dc95723 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 26b8c3a53935b834ba5f7eb4c08d0568 +folderAsset: yes +timeCreated: 1458174645 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Bar.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Bar.cs new file mode 100644 index 000000000..12382c8b4 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Bar.cs @@ -0,0 +1,8 @@ +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToPrefab +{ + public class Bar : MonoBehaviour + { + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Bar.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Bar.cs.meta new file mode 100644 index 000000000..4017215d5 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Bar.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 86870631eb8b52e409ad0b86fd44aad7 +timeCreated: 1458314694 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Bob.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Bob.cs new file mode 100644 index 000000000..df205eeba --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Bob.cs @@ -0,0 +1,13 @@ +using System; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToPrefab +{ + public class Bob : MonoBehaviour + { + [NonSerialized] + [Inject] + public Jim Jim; + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Bob.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Bob.cs.meta new file mode 100644 index 000000000..fb8b415f8 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Bob.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: aeb709c66d821b242b8e5016c31bb2d2 +timeCreated: 1459009627 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Fixture.cs new file mode 100644 index 000000000..131d39214 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Fixture.cs @@ -0,0 +1,165 @@ +using System.Collections.Generic; +using ModestTree.UnityUnitTester; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToPrefab +{ + public class Fixture : MonoTestFixture + { + public GameObject FooPrefab; + public GameObject FooPrefab2; + public GameObject GorpAndQuxPrefab; + public GameObject NorfPrefab; + public GameObject JimAndBobPrefab; + + [Test] + public void TestTransient() + { + Container.Bind().FromPrefab(FooPrefab).AsTransient(); + Container.Bind().FromPrefab(FooPrefab).AsTransient(); + + Container.BindRootResolve(); + + FixtureUtil.AssertComponentCount(Container, 2); + } + + [Test] + public void TestSingle() + { + Container.Bind().To().FromPrefab(FooPrefab).AsSingle(); + Container.Bind().FromPrefab(FooPrefab).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestSingle2() + { + // For ToPrefab, the 'AsSingle' applies to the prefab and not the type, so this is valid + Container.Bind().To().FromPrefab(FooPrefab).AsSingle(); + Container.Bind().FromPrefab(FooPrefab2).AsSingle(); + Container.Bind().FromMethod(ctx => ctx.Container.CreateEmptyGameObject("Foo").AddComponent()); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertComponentCount(Container, 3); + FixtureUtil.AssertNumGameObjects(Container, 3); + } + + [Test] + public void TestSingleIdentifiers() + { + Container.Bind().FromPrefab(FooPrefab).WithGameObjectName("Foo").AsSingle(); + Container.Bind().FromPrefab(FooPrefab).WithGameObjectName("Foo").AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "Foo", 1); + } + + [Test] + public void TestCached1() + { + Container.Bind(typeof(Foo), typeof(Bar)).FromPrefab(FooPrefab).WithGameObjectName("Foo").AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "Foo", 1); + } + + [Test] + [ExpectedException] + [ExpectedValidationException] + public void TestWithArgumentsFail() + { + // They have required arguments + Container.Bind(typeof(Gorp), typeof(Qux)).FromPrefab(GorpAndQuxPrefab).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + } + + [Test] + public void TestWithArguments() + { + Container.Bind(typeof(Gorp), typeof(Qux)) + .FromPrefab(GorpAndQuxPrefab).WithGameObjectName("GorpAndQux").AsCached() + .WithArguments(5, "test1"); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "GorpAndQux", 1); + } + + [Test] + public void TestWithAbstractSearch() + { + // There are three components that implement INorf on this prefab + // and so this should result in a list of 3 INorf's + Container.Bind().FromPrefab(NorfPrefab); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 3); + FixtureUtil.AssertResolveCount(Container, 3); + } + + [Test] + public void TestAbstractBindingConcreteSearch() + { + // Should ignore the Norf2 component on it + Container.Bind().To().FromPrefab(NorfPrefab); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertResolveCount(Container, 2); + } + + [Test] + public void TestCircularDependencies() + { + // Jim and Bob both depend on each other + Container.Bind(typeof(Jim), typeof(Bob)).FromPrefab(JimAndBobPrefab).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + Container.BindAllInterfaces().To().AsSingle(); + } + + public class JimAndBobRunner : IInitializable + { + readonly Bob _bob; + readonly Jim _jim; + + public JimAndBobRunner(Jim jim, Bob bob) + { + _bob = bob; + _jim = jim; + } + + public void Initialize() + { + Assert.IsNotNull(_jim.Bob); + Assert.IsNotNull(_bob.Jim); + + Log.Info("Jim and bob successfully got the other reference"); + } + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Fixture.cs.meta new file mode 100644 index 000000000..9a9366c94 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 9a11ff4a9421f2949993c4dc34f50335 +timeCreated: 1454819941 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo.cs new file mode 100644 index 000000000..4da18171b --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToPrefab +{ + public interface IFoo + { + } + + public class Foo : MonoBehaviour, IFoo + { + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo.cs.meta new file mode 100644 index 000000000..9bec9821e --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f39c997bb2d185144bc18d37878d4ab8 +timeCreated: 1458245958 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo.prefab new file mode 100644 index 000000000..b2df270b5 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo.prefab @@ -0,0 +1,64 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &154292 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 496146} + - 114: {fileID: 11420556} + - 114: {fileID: 11472394} + m_Layer: 0 + m_Name: Foo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &496146 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11420556 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f39c997bb2d185144bc18d37878d4ab8, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11472394 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 86870631eb8b52e409ad0b86fd44aad7, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 154292} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo.prefab.meta new file mode 100644 index 000000000..a10590a8d --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7d3811faab260ce4dab063fd012b42b5 +timeCreated: 1454692704 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo2.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo2.prefab new file mode 100644 index 000000000..8bdb54d44 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo2.prefab @@ -0,0 +1,52 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &154292 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 496146} + - 114: {fileID: 11420556} + m_Layer: 0 + m_Name: Foo2 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &496146 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11420556 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f39c997bb2d185144bc18d37878d4ab8, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 154292} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo2.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo2.prefab.meta new file mode 100644 index 000000000..c22a2e760 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Foo2.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d0fc7ecead470be4d8ac1114be3d9d62 +timeCreated: 1458261082 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Gorp.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Gorp.cs new file mode 100644 index 000000000..8a37f8026 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Gorp.cs @@ -0,0 +1,17 @@ +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToPrefab +{ + public class Gorp : MonoBehaviour + { + [Inject] + string _arg; + + [PostInject] + public void Initialize() + { + Log.Trace("Received arg '{0}' in Gorp", _arg); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Gorp.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Gorp.cs.meta new file mode 100644 index 000000000..b2876cf0c --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Gorp.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cc679fbba1bf0a645957d68235c4771d +timeCreated: 1459002694 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Jim.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Jim.cs new file mode 100644 index 000000000..92ab43e75 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Jim.cs @@ -0,0 +1,13 @@ +using System; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToPrefab +{ + public class Jim : MonoBehaviour + { + [NonSerialized] + [Inject] + public Bob Bob; + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Jim.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Jim.cs.meta new file mode 100644 index 000000000..4fe62bd3e --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Jim.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 78b17c518e97edb498c1ff8a4d914bd5 +timeCreated: 1459009626 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/JimAndBob.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/JimAndBob.prefab new file mode 100644 index 000000000..cf7a49517 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/JimAndBob.prefab @@ -0,0 +1,64 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &124956 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 464534} + - 114: {fileID: 11499784} + - 114: {fileID: 11418142} + m_Layer: 0 + m_Name: JimAndBob + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &464534 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 124956} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11418142 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 124956} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: aeb709c66d821b242b8e5016c31bb2d2, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11499784 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 124956} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 78b17c518e97edb498c1ff8a4d914bd5, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 124956} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/JimAndBob.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/JimAndBob.prefab.meta new file mode 100644 index 000000000..481d93ca5 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/JimAndBob.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1592e529a326aad4b8a0a8c4640f000e +timeCreated: 1459009683 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf.cs new file mode 100644 index 000000000..64f0f0d7b --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf.cs @@ -0,0 +1,13 @@ +using System; +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToPrefab +{ + public interface INorf + { + } + + public class Norf : MonoBehaviour, INorf + { + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf.cs.meta new file mode 100644 index 000000000..ca29f2890 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 91f7cce5532e4cc4796d58d33d783a80 +timeCreated: 1459008624 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf.prefab new file mode 100644 index 000000000..af86ce80c --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf.prefab @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &199570 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 431222} + - 114: {fileID: 11449184} + - 114: {fileID: 11420968} + - 114: {fileID: 11461460} + m_Layer: 0 + m_Name: Norf + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &431222 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 199570} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11420968 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 199570} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 91f7cce5532e4cc4796d58d33d783a80, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11449184 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 199570} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 91f7cce5532e4cc4796d58d33d783a80, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11461460 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 199570} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 8fb03bf3db5129643a756826728ce939, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 199570} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf.prefab.meta new file mode 100644 index 000000000..84a94f909 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3f9121b460e6fb541a5dfd7384d5c03a +timeCreated: 1459008724 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf2.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf2.cs new file mode 100644 index 000000000..37dae6217 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf2.cs @@ -0,0 +1,10 @@ +using System; +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToPrefab +{ + public class Norf2 : MonoBehaviour, INorf + { + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf2.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf2.cs.meta new file mode 100644 index 000000000..c9ba6a310 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Norf2.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 8fb03bf3db5129643a756826728ce939 +timeCreated: 1459008655 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Qux.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Qux.cs new file mode 100644 index 000000000..bb263f716 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Qux.cs @@ -0,0 +1,17 @@ +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToPrefab +{ + public class Qux : MonoBehaviour + { + [Inject] + int _arg; + + [PostInject] + public void Initialize() + { + Log.Trace("Received arg '{0}' in Qux", _arg); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Qux.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Qux.cs.meta new file mode 100644 index 000000000..ea9ec0539 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/Qux.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 914f813dee2b8b248bce3b21eafa7b6e +timeCreated: 1459002695 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/QuxAndGorp.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/QuxAndGorp.prefab new file mode 100644 index 000000000..1928af527 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/QuxAndGorp.prefab @@ -0,0 +1,64 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &154292 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 496146} + - 114: {fileID: 11461012} + - 114: {fileID: 11470700} + m_Layer: 0 + m_Name: QuxAndGorp + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &496146 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11461012 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 914f813dee2b8b248bce3b21eafa7b6e, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11470700 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cc679fbba1bf0a645957d68235c4771d, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 154292} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/QuxAndGorp.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/QuxAndGorp.prefab.meta new file mode 100644 index 000000000..73ce7c0b8 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/QuxAndGorp.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a9f9ff1c71e66294f910610d2194c731 +timeCreated: 1459002680 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/TestToPrefab.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/TestToPrefab.unity new file mode 100644 index 000000000..f43454314 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/TestToPrefab.unity @@ -0,0 +1,160 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &42935781 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 42935785} + - 114: {fileID: 42935783} + - 114: {fileID: 42935782} + m_Layer: 0 + m_Name: SceneCompositionRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &42935782 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 42935781} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 9a11ff4a9421f2949993c4dc34f50335, type: 3} + m_Name: + m_EditorClassIdentifier: + FooPrefab: {fileID: 154292, guid: 7d3811faab260ce4dab063fd012b42b5, type: 2} + FooPrefab2: {fileID: 154292, guid: d0fc7ecead470be4d8ac1114be3d9d62, type: 2} + GorpAndQuxPrefab: {fileID: 154292, guid: a9f9ff1c71e66294f910610d2194c731, type: 2} + NorfPrefab: {fileID: 199570, guid: 3f9121b460e6fb541a5dfd7384d5c03a, type: 2} + JimAndBobPrefab: {fileID: 124956, guid: 1592e529a326aad4b8a0a8c4640f000e, type: 2} +--- !u!114 &42935783 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 42935781} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 42935782} + m_MethodName: TestWithArgumentsFail + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!4 &42935785 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 42935781} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/TestToPrefab.unity.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/TestToPrefab.unity.meta new file mode 100644 index 000000000..b03e4ce68 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefab/TestToPrefab.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6982f48aa0200514ca8251ba55b239b0 +timeCreated: 1458226369 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource.meta new file mode 100644 index 000000000..2a6bc4c71 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 82e107c22aad72445b07c23306db54c7 +folderAsset: yes +timeCreated: 1458255572 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Bar.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Bar.cs new file mode 100644 index 000000000..beb8697ec --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Bar.cs @@ -0,0 +1,8 @@ +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToPrefabResource +{ + public class Bar : MonoBehaviour + { + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Bar.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Bar.cs.meta new file mode 100644 index 000000000..21f2aebb0 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Bar.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 09cb1c767472bd447ab51093e4a17ad3 +timeCreated: 1459015737 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Bob.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Bob.cs new file mode 100644 index 000000000..7fc1aee01 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Bob.cs @@ -0,0 +1,13 @@ +using System; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToPrefabResource +{ + public class Bob : MonoBehaviour + { + [NonSerialized] + [Inject] + public Jim Jim; + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Bob.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Bob.cs.meta new file mode 100644 index 000000000..915a87648 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Bob.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 93bfc10f4bb073945911d600dea398a5 +timeCreated: 1459015737 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Fixture.cs new file mode 100644 index 000000000..a42f3ccb0 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Fixture.cs @@ -0,0 +1,172 @@ +using System.Collections.Generic; +using ModestTree.UnityUnitTester; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToPrefabResource +{ + public class Fixture : MonoTestFixture + { + const string PathPrefix = "TestToPrefabResource/"; + + [Test] + [ExpectedException] + [ExpectedValidationException] + public void TestTransientError() + { + // Validation should detect that it doesn't exist + Container.Bind().FromPrefabResource(PathPrefix + "asdfasdfas").AsTransient(); + + Container.BindRootResolve(); + } + + [Test] + public void TestTransient() + { + Container.Bind().FromPrefabResource(PathPrefix + "Foo").AsTransient(); + Container.Bind().FromPrefabResource(PathPrefix + "Foo").AsTransient(); + + Container.BindRootResolve(); + + FixtureUtil.AssertComponentCount(Container, 2); + } + + [Test] + public void TestSingle() + { + Container.Bind().To().FromPrefabResource(PathPrefix + "Foo").AsSingle(); + Container.Bind().FromPrefabResource(PathPrefix + "Foo").AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestSingle2() + { + // For ToPrefab, the 'AsSingle' applies to the prefab and not the type, so this is valid + Container.Bind().To().FromPrefabResource(PathPrefix + "Foo").AsSingle(); + Container.Bind().FromPrefabResource(PathPrefix + "Foo2").AsSingle(); + Container.Bind().FromMethod(ctx => ctx.Container.CreateEmptyGameObject("Foo").AddComponent()); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertComponentCount(Container, 3); + FixtureUtil.AssertNumGameObjects(Container, 3); + } + + [Test] + public void TestSingleIdentifiers() + { + Container.Bind().FromPrefabResource(PathPrefix + "Foo").WithGameObjectName("Foo").AsSingle(); + Container.Bind().FromPrefabResource(PathPrefix + "Foo").WithGameObjectName("Foo").AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "Foo", 1); + } + + [Test] + public void TestCached1() + { + Container.Bind(typeof(Foo), typeof(Bar)).FromPrefabResource(PathPrefix + "Foo").WithGameObjectName("Foo").AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "Foo", 1); + } + + [Test] + [ExpectedException] + [ExpectedValidationException] + public void TestWithArgumentsFail() + { + // They have required arguments + Container.Bind(typeof(Gorp), typeof(Qux)).FromPrefabResource(PathPrefix + "GorpAndQux").AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + } + + [Test] + public void TestWithArguments() + { + Container.Bind(typeof(Gorp), typeof(Qux)) + .FromPrefabResource(PathPrefix + "GorpAndQux").WithGameObjectName("GorpAndQux").AsCached() + .WithArguments(5, "test1"); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "GorpAndQux", 1); + } + + [Test] + public void TestWithAbstractSearch() + { + // There are three components that implement INorf on this prefab + // and so this should result in a list of 3 INorf's + Container.Bind().FromPrefabResource(PathPrefix + "Norf"); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 3); + FixtureUtil.AssertResolveCount(Container, 3); + } + + [Test] + public void TestAbstractBindingConcreteSearch() + { + // Should ignore the Norf2 component on it + Container.Bind().To().FromPrefabResource(PathPrefix + "Norf"); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertResolveCount(Container, 2); + } + + [Test] + public void TestCircularDependencies() + { + // Jim and Bob both depend on each other + Container.Bind(typeof(Jim), typeof(Bob)).FromPrefabResource(PathPrefix + "JimAndBob").AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + Container.BindAllInterfaces().To().AsSingle(); + } + + public class JimAndBobRunner : IInitializable + { + readonly Bob _bob; + readonly Jim _jim; + + public JimAndBobRunner(Jim jim, Bob bob) + { + _bob = bob; + _jim = jim; + } + + public void Initialize() + { + Assert.IsNotNull(_jim.Bob); + Assert.IsNotNull(_bob.Jim); + + Log.Info("Jim and bob successfully got the other reference"); + } + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Fixture.cs.meta new file mode 100644 index 000000000..be3e3d5f8 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 4306a5fdd341f47499a87de2cb158a46 +timeCreated: 1458255591 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Foo.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Foo.cs new file mode 100644 index 000000000..caeabebc7 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Foo.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToPrefabResource +{ + public interface IFoo + { + } + + public class Foo : MonoBehaviour, IFoo + { + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Foo.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Foo.cs.meta new file mode 100644 index 000000000..e43ec2b53 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Foo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c4fe41d55bac23c408a020415051f590 +timeCreated: 1459015737 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Gorp.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Gorp.cs new file mode 100644 index 000000000..75e6bf180 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Gorp.cs @@ -0,0 +1,17 @@ +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToPrefabResource +{ + public class Gorp : MonoBehaviour + { + [Inject] + string _arg; + + [PostInject] + public void Initialize() + { + Log.Trace("Received arg '{0}' in Gorp", _arg); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Gorp.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Gorp.cs.meta new file mode 100644 index 000000000..9874b539e --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Gorp.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 93bd1149166ed44478c2e59b34fbfc9b +timeCreated: 1459015737 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Jim.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Jim.cs new file mode 100644 index 000000000..0cd705544 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Jim.cs @@ -0,0 +1,13 @@ +using System; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToPrefabResource +{ + public class Jim : MonoBehaviour + { + [NonSerialized] + [Inject] + public Bob Bob; + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Jim.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Jim.cs.meta new file mode 100644 index 000000000..2ca71b84c --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Jim.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6dd802b9b69c51443af5311b06b79ca0 +timeCreated: 1459015737 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Norf.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Norf.cs new file mode 100644 index 000000000..3a544507a --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Norf.cs @@ -0,0 +1,13 @@ +using System; +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToPrefabResource +{ + public interface INorf + { + } + + public class Norf : MonoBehaviour, INorf + { + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Norf.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Norf.cs.meta new file mode 100644 index 000000000..defc63a37 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Norf.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 434e869aa9c49e046b97da50b0dfa819 +timeCreated: 1459015737 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Norf2.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Norf2.cs new file mode 100644 index 000000000..66071fd61 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Norf2.cs @@ -0,0 +1,10 @@ +using System; +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToPrefabResource +{ + public class Norf2 : MonoBehaviour, INorf + { + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Norf2.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Norf2.cs.meta new file mode 100644 index 000000000..20d270be4 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Norf2.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cf6600df40401e046af9c2ebfbf58b46 +timeCreated: 1459015737 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Qux.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Qux.cs new file mode 100644 index 000000000..1114f4ad9 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Qux.cs @@ -0,0 +1,17 @@ +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToPrefabResource +{ + public class Qux : MonoBehaviour + { + [Inject] + int _arg; + + [PostInject] + public void Initialize() + { + Log.Trace("Received arg '{0}' in Qux", _arg); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Qux.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Qux.cs.meta new file mode 100644 index 000000000..60c540b9d --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Qux.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b244b0173d6179840b86ed145aaa6bb2 +timeCreated: 1459015737 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources.meta new file mode 100644 index 000000000..84bb69a6b --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b4cf3e3fda8e2cf48ae3c2cbada441dd +folderAsset: yes +timeCreated: 1459015750 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource.meta new file mode 100644 index 000000000..db3b9f894 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1fb22ad99723e0d4ea93fcd5fc7b4f81 +folderAsset: yes +timeCreated: 1459015756 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Foo.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Foo.prefab new file mode 100644 index 000000000..e8788a4b1 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Foo.prefab @@ -0,0 +1,64 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &154292 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 496146} + - 114: {fileID: 11408316} + - 114: {fileID: 11424772} + m_Layer: 0 + m_Name: Foo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &496146 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11408316 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 09cb1c767472bd447ab51093e4a17ad3, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11424772 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c4fe41d55bac23c408a020415051f590, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 154292} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Foo.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Foo.prefab.meta new file mode 100644 index 000000000..320d90df2 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Foo.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f35ac9a6aa0dab64bafb5461a8fd393a +timeCreated: 1459015737 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Foo2.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Foo2.prefab new file mode 100644 index 000000000..50fa4ba76 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Foo2.prefab @@ -0,0 +1,52 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &154292 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 496146} + - 114: {fileID: 11415242} + m_Layer: 0 + m_Name: Foo2 + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &496146 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11415242 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: c4fe41d55bac23c408a020415051f590, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 154292} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Foo2.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Foo2.prefab.meta new file mode 100644 index 000000000..087fe93e0 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Foo2.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 54bc08272e3f439458c8c656d27da5bc +timeCreated: 1459015737 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/GorpAndQux.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/GorpAndQux.prefab new file mode 100644 index 000000000..2edc6f5c9 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/GorpAndQux.prefab @@ -0,0 +1,64 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &154292 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 496146} + - 114: {fileID: 11498922} + - 114: {fileID: 11419060} + m_Layer: 0 + m_Name: GorpAndQux + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &496146 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11419060 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 93bd1149166ed44478c2e59b34fbfc9b, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11498922 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 154292} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b244b0173d6179840b86ed145aaa6bb2, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 154292} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/GorpAndQux.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/GorpAndQux.prefab.meta new file mode 100644 index 000000000..8800bfe7b --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/GorpAndQux.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bfe2502efa3e0b3438c53be39dad6c3c +timeCreated: 1459015737 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/JimAndBob.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/JimAndBob.prefab new file mode 100644 index 000000000..ad5522946 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/JimAndBob.prefab @@ -0,0 +1,64 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &124956 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 464534} + - 114: {fileID: 11479894} + - 114: {fileID: 11448468} + m_Layer: 0 + m_Name: JimAndBob + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &464534 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 124956} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11448468 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 124956} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 93bfc10f4bb073945911d600dea398a5, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11479894 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 124956} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6dd802b9b69c51443af5311b06b79ca0, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 124956} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/JimAndBob.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/JimAndBob.prefab.meta new file mode 100644 index 000000000..90c2a1773 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/JimAndBob.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 588f499d9ffe8944da19657e601ffa61 +timeCreated: 1459015737 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Norf.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Norf.prefab new file mode 100644 index 000000000..0f97a1d8e --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Norf.prefab @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &199570 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 431222} + - 114: {fileID: 11458152} + - 114: {fileID: 11453902} + - 114: {fileID: 11417458} + m_Layer: 0 + m_Name: Norf + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &431222 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 199570} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11417458 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 199570} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cf6600df40401e046af9c2ebfbf58b46, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11453902 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 199570} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 434e869aa9c49e046b97da50b0dfa819, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11458152 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 199570} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 434e869aa9c49e046b97da50b0dfa819, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 199570} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Norf.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Norf.prefab.meta new file mode 100644 index 000000000..5bd6f4b20 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/Resources/TestToPrefabResource/Norf.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a4833165ddddda347b80b96e1a704b4e +timeCreated: 1459015737 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/TestToPrefabResource.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/TestToPrefabResource.unity new file mode 100644 index 000000000..51a7ac525 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/TestToPrefabResource.unity @@ -0,0 +1,155 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &978433746 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 978433749} + - 114: {fileID: 978433747} + - 114: {fileID: 978433750} + m_Layer: 0 + m_Name: SceneCompositionRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &978433747 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 978433750} + m_MethodName: 546573745472616e7369656e744572726f72 + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: 556e697479456e67696e652e4f626a6563742c20556e697479456e67696e65 + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!4 &978433749 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &978433750 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 4306a5fdd341f47499a87de2cb158a46, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/TestToPrefabResource.unity.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/TestToPrefabResource.unity.meta new file mode 100644 index 000000000..bfd154a13 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToPrefabResource/TestToPrefabResource.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a7f049aa3d573164eaafb42cac0eed54 +timeCreated: 1458255591 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource.meta new file mode 100644 index 000000000..1e2071747 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c2773b71118022144941faaa397a4874 +folderAsset: yes +timeCreated: 1458258653 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Fixture.cs new file mode 100644 index 000000000..0f2efed39 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Fixture.cs @@ -0,0 +1,91 @@ +using System.Collections.Generic; +using ModestTree.UnityUnitTester; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToResource +{ + public class Fixture : MonoTestFixture + { + const string ResourcePath = "TestToResource/TestTexture"; + const string ResourcePath2 = "TestToResource/TestTexture2"; + + [Test] + public void TestBasic() + { + Container.Bind().FromResource(ResourcePath); + + Container.Bind().FromGameObject().AsSingle().WithArguments(1); + Container.BindRootResolve(); + } + + [Test] + public void TestTransient() + { + Container.Bind().FromResource(ResourcePath).AsTransient(); + Container.Bind().FromResource(ResourcePath); + Container.Bind().To().FromResource(ResourcePath); + + Container.Bind().FromGameObject().AsSingle().WithArguments(3); + Container.BindRootResolve(); + } + + [Test] + public void TestCached() + { + Container.Bind().FromResource(ResourcePath).AsCached(); + + Container.Bind().FromGameObject().AsSingle().WithArguments(1); + Container.BindRootResolve(); + } + + [Test] + public void TestSingle() + { + Container.Bind().FromResource(ResourcePath).AsSingle(); + Container.Bind().FromResource(ResourcePath).AsSingle(); + + Container.Bind().FromGameObject().AsSingle().WithArguments(2); + Container.BindRootResolve(); + } + + [Test] + [ExpectedException] + [ExpectedValidationException] + public void TestSingleWithError() + { + Container.Bind().FromResource(ResourcePath).AsSingle(); + Container.Bind().FromResource(ResourcePath2).AsSingle(); + + Container.Bind().FromGameObject().AsSingle().WithArguments(2); + Container.BindRootResolve(); + } + + public class Runner : MonoBehaviour + { + List _textures; + + [PostInject] + public void Construct(List textures, int expectedAmount) + { + _textures = textures; + + Assert.IsEqual(textures.Count, expectedAmount); + } + + void OnGUI() + { + int top = 0; + + foreach (var tex in _textures) + { + var rect = new Rect(0, top, Screen.width * 0.5f, Screen.height * 0.5f); + + GUI.DrawTexture(rect, tex); + + top += 200; + } + } + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Fixture.cs.meta new file mode 100644 index 000000000..bb91ebcd6 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f57a7c2484f55fe409373e5dc7c37a69 +timeCreated: 1458258911 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources.meta new file mode 100644 index 000000000..42a9dba9e --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9b025ceac67a6154fbbd08ef902d4f1d +folderAsset: yes +timeCreated: 1458258883 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource.meta new file mode 100644 index 000000000..aca0f056b --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a0e9026f52b719744a3a6faf1e1833a9 +folderAsset: yes +timeCreated: 1458258887 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource/TestTexture.png b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource/TestTexture.png new file mode 100644 index 000000000..ae559b970 Binary files /dev/null and b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource/TestTexture.png differ diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource/TestTexture.png.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource/TestTexture.png.meta new file mode 100644 index 000000000..683ec6ad7 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource/TestTexture.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 8de083ec593046642b2fa0c94a0bfd21 +timeCreated: 1456063223 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource/TestTexture2.png b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource/TestTexture2.png new file mode 100644 index 000000000..d888c32d5 Binary files /dev/null and b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource/TestTexture2.png differ diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource/TestTexture2.png.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource/TestTexture2.png.meta new file mode 100644 index 000000000..9da4a3a1e --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/Resources/TestToResource/TestTexture2.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: b425a440f0e76634497b592404c9d18b +timeCreated: 1458260282 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/TestToResource.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/TestToResource.unity new file mode 100644 index 000000000..98851ea2b --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/TestToResource.unity @@ -0,0 +1,155 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &978433746 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 978433749} + - 114: {fileID: 978433747} + - 114: {fileID: 978433750} + m_Layer: 0 + m_Name: SceneCompositionRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &978433747 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 978433750} + m_MethodName: 5465737453696e676c65 + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: 556e697479456e67696e652e4f626a6563742c20556e697479456e67696e65 + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!4 &978433749 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &978433750 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f57a7c2484f55fe409373e5dc7c37a69, type: 3} + m_Name: + m_EditorClassIdentifier: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/TestToResource.unity.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/TestToResource.unity.meta new file mode 100644 index 000000000..8ce2d4df6 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToResource/TestToResource.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4be1bef531c880642900d751df219475 +timeCreated: 1458258911 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab.meta new file mode 100644 index 000000000..1864f8683 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 301319ddd5676674cbe6680a84822d00 +folderAsset: yes +timeCreated: 1460507275 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Bar.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Bar.cs new file mode 100644 index 000000000..0f1be14e5 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Bar.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToSubContainerPrefab +{ + public class Bar : MonoBehaviour + { + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Bar.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Bar.cs.meta new file mode 100644 index 000000000..af83b1a81 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Bar.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2161a6f5a67bb7749bb74037a259ca72 +timeCreated: 1460644405 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Fixture.cs new file mode 100644 index 000000000..8e92ae512 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Fixture.cs @@ -0,0 +1,185 @@ +using System.Collections.Generic; +using ModestTree.UnityUnitTester; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToSubContainerPrefab +{ + public class Fixture : MonoTestFixture + { + [SerializeField] + GameObject _fooPrefab; + + [Test] + public void TestSelfSingle() + { + Container.Bind().FromSubContainerResolve() + .ByPrefab(_fooPrefab).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestSelfTransient() + { + Container.Bind().FromSubContainerResolve().ByPrefab(_fooPrefab).AsTransient(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 3); + FixtureUtil.AssertComponentCount(Container, 3); + } + + [Test] + public void TestSelfCached() + { + Container.Bind().FromSubContainerResolve().ByPrefab(_fooPrefab).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestSelfSingleMultipleContracts() + { + Container.Bind().FromSubContainerResolve().ByPrefab(_fooPrefab).AsSingle(); + Container.Bind().FromSubContainerResolve().ByPrefab(_fooPrefab).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestSelfCachedMultipleContracts() + { + Container.Bind(typeof(Foo), typeof(Bar)).FromSubContainerResolve().ByPrefab(_fooPrefab).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestSelfTransientMultipleContracts() + { + Container.Bind(typeof(Foo), typeof(Bar)).FromSubContainerResolve().ByPrefab(_fooPrefab).AsTransient(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 2); + FixtureUtil.AssertComponentCount(Container, 2); + FixtureUtil.AssertComponentCount(Container, 2); + } + + [Test] + public void TestConcreteSingle() + { + Container.Bind().To().FromSubContainerResolve().ByPrefab(_fooPrefab).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestConcreteTransient() + { + Container.Bind().To().FromSubContainerResolve().ByPrefab(_fooPrefab).AsTransient(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 3); + FixtureUtil.AssertComponentCount(Container, 3); + } + + [Test] + public void TestConcreteCached() + { + Container.Bind().To().FromSubContainerResolve().ByPrefab(_fooPrefab).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestConcreteSingleMultipleContracts() + { + Container.Bind().To().FromSubContainerResolve().ByPrefab(_fooPrefab).AsSingle(); + Container.Bind().FromSubContainerResolve().ByPrefab(_fooPrefab).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestConcreteCachedMultipleContracts() + { + Container.Bind(typeof(Foo), typeof(IFoo)).To().FromSubContainerResolve().ByPrefab(_fooPrefab).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + [ExpectedException] + [ExpectedValidationException] + public void TestSelfIdentifiersFails() + { + Container.Bind().FromSubContainerResolve().ByPrefab(_fooPrefab).AsSingle(); + + Container.BindRootResolve(); + } + + [Test] + public void TestSelfIdentifiers() + { + Container.Bind().FromSubContainerResolve("gorp").ByPrefab(_fooPrefab).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Fixture.cs.meta new file mode 100644 index 000000000..4bc0381ea --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 42de6818a6bb1bb42864b50b58cdcd7a +timeCreated: 1460507335 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Foo.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Foo.cs new file mode 100644 index 000000000..2790e0b4e --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Foo.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToSubContainerPrefab +{ + public interface IFoo + { + } + + public class Foo : MonoBehaviour, IFoo + { + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Foo.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Foo.cs.meta new file mode 100644 index 000000000..94c723c39 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Foo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 6997e435baf0c60488bc2bc179014813 +timeCreated: 1460508139 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Foo.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Foo.prefab new file mode 100644 index 000000000..f87b07515 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Foo.prefab @@ -0,0 +1,139 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &151926 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 436462} + - 114: {fileID: 11426760} + - 114: {fileID: 11423502} + m_Layer: 0 + m_Name: Foo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &162920 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 406566} + - 114: {fileID: 11460120} + - 114: {fileID: 11429022} + - 114: {fileID: 11473484} + m_Layer: 0 + m_Name: Foo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &406566 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 162920} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 436462} + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!4 &436462 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 151926} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 406566} + m_RootOrder: 0 +--- !u!114 &11423502 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 151926} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0166d8ff8d905b048b2448179e1f5d11, type: 3} + m_Name: + m_EditorClassIdentifier: + _components: + - {fileID: 11426760} + _identifier: + _compositionRoot: {fileID: 0} + _bindType: 0 +--- !u!114 &11426760 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 151926} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 6997e435baf0c60488bc2bc179014813, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11429022 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 162920} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2161a6f5a67bb7749bb74037a259ca72, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11460120 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 162920} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 08eca9f7688a0a24685b89133b020c8e, type: 3} + m_Name: + m_EditorClassIdentifier: + _installers: + - {fileID: 11473484} + _installerPrefabs: [] + _scriptableObjectInstallers: [] + _facade: {fileID: 0} +--- !u!114 &11473484 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 162920} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0a2394e0baff5a347bdf60d1c2c913d1, type: 3} + m_Name: + m_EditorClassIdentifier: + _bar: {fileID: 11429022} +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 162920} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Foo.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Foo.prefab.meta new file mode 100644 index 000000000..222002b23 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Foo.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 878b989aa92d3654f8507e4880b04678 +timeCreated: 1460509291 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/FooInstaller.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/FooInstaller.cs new file mode 100644 index 000000000..55d0772f3 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/FooInstaller.cs @@ -0,0 +1,18 @@ +using UnityEngine; +using System.Collections; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToSubContainerPrefab +{ + public class FooInstaller : MonoInstaller + { + [SerializeField] + Bar _bar; + + public override void InstallBindings() + { + Container.BindInstance(_bar); + Container.Bind("gorp").AsSingle(); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/FooInstaller.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/FooInstaller.cs.meta new file mode 100644 index 000000000..9ded5b7c1 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/FooInstaller.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0a2394e0baff5a347bdf60d1c2c913d1 +timeCreated: 1460644513 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Gorp.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Gorp.cs new file mode 100644 index 000000000..f9881edb0 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Gorp.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToSubContainerPrefab +{ + public class Gorp + { + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Gorp.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Gorp.cs.meta new file mode 100644 index 000000000..bad574f02 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/Gorp.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: e7443e55301b94c48944434e69fb7828 +timeCreated: 1460644406 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/TestToSubContainerPrefab.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/TestToSubContainerPrefab.unity new file mode 100644 index 000000000..e6768b56a --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/TestToSubContainerPrefab.unity @@ -0,0 +1,156 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &42935781 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 42935785} + - 114: {fileID: 42935783} + - 114: {fileID: 42935782} + m_Layer: 0 + m_Name: SceneCompositionRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &42935782 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 42935781} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 42de6818a6bb1bb42864b50b58cdcd7a, type: 3} + m_Name: + m_EditorClassIdentifier: + _fooPrefab: {fileID: 162920, guid: 878b989aa92d3654f8507e4880b04678, type: 2} +--- !u!114 &42935783 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 42935781} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 42935782} + m_MethodName: TestSelfSingle + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!4 &42935785 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 42935781} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/TestToSubContainerPrefab.unity.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/TestToSubContainerPrefab.unity.meta new file mode 100644 index 000000000..9c4ce78cd --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefab/TestToSubContainerPrefab.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0bc0bb033bb3a6241a4ddfc6cb236142 +timeCreated: 1460507308 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource.meta new file mode 100644 index 000000000..e6bdcf5ca --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f8bf6921de58d4e4cae8ef709e6a8994 +folderAsset: yes +timeCreated: 1460654570 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Bar.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Bar.cs new file mode 100644 index 000000000..24e957292 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Bar.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToSubContainerPrefabResource +{ + public class Bar : MonoBehaviour + { + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Bar.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Bar.cs.meta new file mode 100644 index 000000000..cf891cf47 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Bar.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 850feee7ebf0de346ba632c2b2abdc64 +timeCreated: 1460654591 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Fixture.cs new file mode 100644 index 000000000..d5a1a96db --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Fixture.cs @@ -0,0 +1,195 @@ +using System.Collections.Generic; +using ModestTree.UnityUnitTester; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToSubContainerPrefabResource +{ + public class Fixture : MonoTestFixture + { + const string PathPrefix = "ToSubContainerPrefabResource/"; + const string FooResourcePath = PathPrefix + "FooSubContainer"; + + [Test] + [ExpectedException] + [ExpectedValidationException] + public void TestTransientError() + { + // Validation should detect that it doesn't exist + Container.Bind().FromSubContainerResolve().ByPrefabResource(PathPrefix + "asdfasdfas").AsTransient(); + + Container.BindRootResolve(); + } + + [Test] + public void TestSelfSingle() + { + Container.Bind().FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestSelfTransient() + { + Container.Bind().FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsTransient(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 3); + FixtureUtil.AssertComponentCount(Container, 3); + } + + [Test] + public void TestSelfCached() + { + Container.Bind().FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestSelfSingleMultipleContracts() + { + Container.Bind().FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsSingle(); + Container.Bind().FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestSelfCachedMultipleContracts() + { + Container.Bind(typeof(Foo), typeof(Bar)).FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestSelfTransientMultipleContracts() + { + Container.Bind(typeof(Foo), typeof(Bar)).FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsTransient(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 2); + FixtureUtil.AssertComponentCount(Container, 2); + FixtureUtil.AssertComponentCount(Container, 2); + } + + [Test] + public void TestConcreteSingle() + { + Container.Bind().To().FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestConcreteTransient() + { + Container.Bind().To().FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsTransient(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 3); + FixtureUtil.AssertComponentCount(Container, 3); + } + + [Test] + public void TestConcreteCached() + { + Container.Bind().To().FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestConcreteSingleMultipleContracts() + { + Container.Bind().To().FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsSingle(); + Container.Bind().FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + public void TestConcreteCachedMultipleContracts() + { + Container.Bind(typeof(Foo), typeof(IFoo)).To().FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsCached(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertComponentCount(Container, 1); + } + + [Test] + [ExpectedException] + [ExpectedValidationException] + public void TestSelfIdentifiersFails() + { + Container.Bind().FromSubContainerResolve().ByPrefabResource(FooResourcePath).AsSingle(); + + Container.BindRootResolve(); + } + + [Test] + public void TestSelfIdentifiers() + { + Container.Bind().FromSubContainerResolve("gorp").ByPrefabResource(FooResourcePath).AsSingle(); + + Container.BindRootResolve(); + Container.BindRootResolve(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Fixture.cs.meta new file mode 100644 index 000000000..1fe64dd99 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: cb19f83a1a7aa2a4ab76bc3681bacb33 +timeCreated: 1460654592 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Foo.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Foo.cs new file mode 100644 index 000000000..e0f1a96a4 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Foo.cs @@ -0,0 +1,12 @@ +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToSubContainerPrefabResource +{ + public interface IFoo + { + } + + public class Foo : MonoBehaviour, IFoo + { + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Foo.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Foo.cs.meta new file mode 100644 index 000000000..148bf5762 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Foo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b3d9dd215537204498109ca7ed42833c +timeCreated: 1460654592 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/FooInstaller.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/FooInstaller.cs new file mode 100644 index 000000000..eb97e7df7 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/FooInstaller.cs @@ -0,0 +1,18 @@ +using UnityEngine; +using System.Collections; +using Zenject; + +namespace ModestTree.Tests.Zenject.ToSubContainerPrefabResource +{ + public class FooInstaller : MonoInstaller + { + [SerializeField] + Bar _bar; + + public override void InstallBindings() + { + Container.BindInstance(_bar); + Container.Bind("gorp").AsSingle(); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/FooInstaller.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/FooInstaller.cs.meta new file mode 100644 index 000000000..89e3ff664 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/FooInstaller.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a30bc985de2744a49add38b40ccf532a +timeCreated: 1460654592 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Gorp.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Gorp.cs new file mode 100644 index 000000000..2265fcf0a --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Gorp.cs @@ -0,0 +1,9 @@ +using UnityEngine; + +namespace ModestTree.Tests.Zenject.ToSubContainerPrefabResource +{ + public class Gorp + { + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Gorp.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Gorp.cs.meta new file mode 100644 index 000000000..3b94dddfb --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Gorp.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ddd55da12d9bf754fb0752461ce83ab7 +timeCreated: 1460654592 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Resources.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Resources.meta new file mode 100644 index 000000000..fc4f5c0e3 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f0777618bfbe35a428414971e526b9b2 +folderAsset: yes +timeCreated: 1460654581 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Resources/ToSubContainerPrefabResource.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Resources/ToSubContainerPrefabResource.meta new file mode 100644 index 000000000..46c54b338 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Resources/ToSubContainerPrefabResource.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b7bbc41a31e80f44fad482d1305b62f5 +folderAsset: yes +timeCreated: 1460654658 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Resources/ToSubContainerPrefabResource/FooSubContainer.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Resources/ToSubContainerPrefabResource/FooSubContainer.prefab new file mode 100644 index 000000000..6e23ed205 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Resources/ToSubContainerPrefabResource/FooSubContainer.prefab @@ -0,0 +1,139 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &151926 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 436462} + - 114: {fileID: 11413310} + - 114: {fileID: 11423502} + m_Layer: 0 + m_Name: Foo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &162920 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 406566} + - 114: {fileID: 11460120} + - 114: {fileID: 11497872} + - 114: {fileID: 11477890} + m_Layer: 0 + m_Name: FooSubContainer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &406566 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 162920} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -37.141693, y: 4.1177154, z: 8.340115} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 436462} + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!4 &436462 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 151926} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 406566} + m_RootOrder: 0 +--- !u!114 &11413310 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 151926} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: b3d9dd215537204498109ca7ed42833c, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11423502 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 151926} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0166d8ff8d905b048b2448179e1f5d11, type: 3} + m_Name: + m_EditorClassIdentifier: + _components: + - {fileID: 11413310} + _identifier: + _compositionRoot: {fileID: 0} + _bindType: 0 +--- !u!114 &11460120 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 162920} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 08eca9f7688a0a24685b89133b020c8e, type: 3} + m_Name: + m_EditorClassIdentifier: + _installers: + - {fileID: 11497872} + _installerPrefabs: [] + _scriptableObjectInstallers: [] + _facade: {fileID: 0} +--- !u!114 &11477890 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 162920} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 850feee7ebf0de346ba632c2b2abdc64, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11497872 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 162920} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a30bc985de2744a49add38b40ccf532a, type: 3} + m_Name: + m_EditorClassIdentifier: + _bar: {fileID: 11477890} +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 162920} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Resources/ToSubContainerPrefabResource/FooSubContainer.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Resources/ToSubContainerPrefabResource/FooSubContainer.prefab.meta new file mode 100644 index 000000000..0474d5af4 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/Resources/ToSubContainerPrefabResource/FooSubContainer.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: c9bcc6f4dae8ac247a0198aeef995c13 +timeCreated: 1460654592 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/TestToSubContainerPrefabResource.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/TestToSubContainerPrefabResource.unity new file mode 100644 index 000000000..a38297c48 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/TestToSubContainerPrefabResource.unity @@ -0,0 +1,155 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &42935781 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 42935785} + - 114: {fileID: 42935783} + - 114: {fileID: 42935782} + m_Layer: 0 + m_Name: SceneCompositionRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &42935782 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 42935781} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: cb19f83a1a7aa2a4ab76bc3681bacb33, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &42935783 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 42935781} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 42935782} + m_MethodName: + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!4 &42935785 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 42935781} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/TestToSubContainerPrefabResource.unity.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/TestToSubContainerPrefabResource.unity.meta new file mode 100644 index 000000000..42eb11189 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Bindings/TestToSubContainerPrefabResource/TestToSubContainerPrefabResource.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9427c09e3f2c1304fbe67d8c62fe82ed +timeCreated: 1460654591 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories.meta new file mode 100644 index 000000000..c313716dd --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1cb0b193dc8027b4eba4d3cd4e935076 +folderAsset: yes +timeCreated: 1462057592 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory.meta new file mode 100644 index 000000000..aad56df31 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0d2ec9fa00b238343bfe6aed69180d7b +folderAsset: yes +timeCreated: 1461165656 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Fixture.cs new file mode 100644 index 000000000..ae55cc8b1 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Fixture.cs @@ -0,0 +1,43 @@ +using ModestTree.UnityUnitTester; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.TestPrefabFactory +{ + public class Fixture : MonoTestFixture + { + public GameObject FooPrefab; + + [Test] + public void Test1() + { + Container.Bind().ToSelf().AsSingle(); + Container.Bind().To().AsSingle().WithArguments(FooPrefab); + } + + public class FooFactory : PrefabFactory + { + } + + public class Runner : IInitializable + { + readonly GameObject _prefab; + readonly FooFactory _fooFactory; + + public Runner( + FooFactory fooFactory, + GameObject prefab) + { + _prefab = prefab; + _fooFactory = fooFactory; + } + + public void Initialize() + { + var foo = _fooFactory.Create(_prefab); + + Assert.That(foo.WasInitialized); + } + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Fixture.cs.meta new file mode 100644 index 000000000..c6f6b44f0 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d7659c77abc45bc4c8e6246b1c584bbf +timeCreated: 1461165705 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Foo.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Foo.cs new file mode 100644 index 000000000..c7cad9373 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Foo.cs @@ -0,0 +1,17 @@ +using System; +using Zenject; +using UnityEngine; + +namespace ModestTree.Tests.Zenject.TestPrefabFactory +{ + public class Foo : MonoBehaviour + { + public bool WasInitialized; + + [PostInject] + public void Init() + { + WasInitialized = true; + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Foo.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Foo.cs.meta new file mode 100644 index 000000000..bf76f58c6 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Foo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 724cacdf997720a47b671d0a4dc6bb0f +timeCreated: 1461166024 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Foo.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Foo.prefab new file mode 100644 index 000000000..c24a78095 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Foo.prefab @@ -0,0 +1,53 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &130070 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 462884} + - 114: {fileID: 11421454} + m_Layer: 0 + m_Name: Foo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &462884 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 130070} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -37.141693, y: 4.1177154, z: 8.340115} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11421454 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 130070} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 724cacdf997720a47b671d0a4dc6bb0f, type: 3} + m_Name: + m_EditorClassIdentifier: + WasInitialized: 0 +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 130070} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Foo.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Foo.prefab.meta new file mode 100644 index 000000000..d8854f9e9 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/Foo.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 54246954ae9afed40ad0e818f0d1702c +timeCreated: 1461166035 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/TestPrefabFactory.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/TestPrefabFactory.unity new file mode 100644 index 000000000..41f0849dd --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/TestPrefabFactory.unity @@ -0,0 +1,156 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &978433746 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 978433749} + - 114: {fileID: 978433747} + - 114: {fileID: 978433750} + m_Layer: 0 + m_Name: SceneCompositionRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &978433747 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 978433750} + m_MethodName: Test1 + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!4 &978433749 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &978433750 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d7659c77abc45bc4c8e6246b1c584bbf, type: 3} + m_Name: + m_EditorClassIdentifier: + FooPrefab: {fileID: 130070, guid: 54246954ae9afed40ad0e818f0d1702c, type: 2} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/TestPrefabFactory.unity.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/TestPrefabFactory.unity.meta new file mode 100644 index 000000000..0aa535ff5 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/PrefabFactory/TestPrefabFactory.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72fc368c654821540b1cfba0e9bd3bc3 +timeCreated: 1461165690 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory.meta new file mode 100644 index 000000000..cbe1535bb --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: d40783ef8557dc74680d885aac004f2b +folderAsset: yes +timeCreated: 1459022918 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Fixture.cs new file mode 100644 index 000000000..5551d56d1 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Fixture.cs @@ -0,0 +1,214 @@ +using ModestTree.UnityUnitTester; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.TestBindFactory +{ + public class Fixture : MonoTestFixture + { + public GameObject FooPrefab; + public GameObject FooSubContainerPrefab; + + [Test] + public void TestToGameObjectSelf() + { + Container.BindFactory().FromGameObject(); + + FixtureUtil.CallFactoryCreateMethod(Container); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + [ExpectedException] + [ExpectedValidationException] + public void TestToGameObjectSelfFail() + { + Container.BindFactory().FromGameObject(); + + FixtureUtil.CallFactoryCreateMethod(Container); + } + + [Test] + public void TestToGameObjectConcrete() + { + Container.BindFactory().To().FromGameObject(); + + FixtureUtil.CallFactoryCreateMethod(Container); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToMonoBehaviourSelf() + { + var gameObject = Container.CreateEmptyGameObject("foo"); + + Container.BindFactory().FromComponent(gameObject); + + FixtureUtil.CallFactoryCreateMethod(Container); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + [ExpectedException] + [ExpectedValidationException] + public void TestToMonoBehaviourSelfFail() + { + Container.BindFactory().FromComponent((GameObject)null); + } + + [Test] + public void TestToMonoBehaviourConcrete() + { + var gameObject = Container.CreateEmptyGameObject("foo"); + + Container.BindFactory().To().FromComponent(gameObject); + + FixtureUtil.CallFactoryCreateMethod(Container); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToPrefabSelf() + { + Container.BindFactory().FromPrefab(FooPrefab).WithGameObjectName("asdf"); + + FixtureUtil.CallFactoryCreateMethod(Container); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); + } + + [Test] + [ExpectedException] + [ExpectedValidationException] + public void TestToPrefabSelfFail() + { + // Foo3 is not on the prefab + Container.BindFactory().FromPrefab(FooPrefab); + + FixtureUtil.CallFactoryCreateMethod(Container); + } + + [Test] + public void TestToPrefabConcrete() + { + Container.BindFactory().To().FromPrefab(FooPrefab).WithGameObjectName("asdf"); + + FixtureUtil.CallFactoryCreateMethod(Container); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); + } + + [Test] + public void TestToResourceSelf() + { + Container.BindFactory>() + .FromResource("TestBindFactory/TestTexture"); + Container.BindRootResolve>(); + + FixtureUtil.CallFactoryCreateMethod>(Container); + } + + [Test] + public void TestToResource() + { + Container.BindFactory>() + .To().FromResource("TestBindFactory/TestTexture"); + Container.BindRootResolve>(); + } + + [Test] + public void TestToPrefabResourceSelf() + { + Container.BindFactory().FromPrefabResource("TestBindFactory/Foo").WithGameObjectName("asdf"); + + FixtureUtil.CallFactoryCreateMethod(Container); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); + } + + [Test] + public void TestToPrefabResourceConcrete() + { + Container.BindFactory().To().FromPrefabResource("TestBindFactory/Foo").WithGameObjectName("asdf"); + + FixtureUtil.CallFactoryCreateMethod(Container); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); + } + + [Test] + public void TestToSubContainerPrefabSelf() + { + Container.BindFactory().FromSubContainerResolve().ByPrefab(FooSubContainerPrefab); + + FixtureUtil.CallFactoryCreateMethod(Container); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToSubContainerPrefabConcrete() + { + Container.BindFactory() + .To().FromSubContainerResolve().ByPrefab(FooSubContainerPrefab); + + FixtureUtil.CallFactoryCreateMethod(Container); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToSubContainerPrefabResourceSelf() + { + Container.BindFactory() + .FromSubContainerResolve().ByPrefabResource("TestBindFactory/FooSubContainer"); + + FixtureUtil.CallFactoryCreateMethod(Container); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToSubContainerPrefabResourceConcrete() + { + Container.BindFactory() + .To().FromSubContainerResolve().ByPrefabResource("TestBindFactory/FooSubContainer"); + + FixtureUtil.CallFactoryCreateMethod(Container); + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + public class Foo3 : MonoBehaviour + { + public class Factory : Factory + { + } + } + + public class Foo2 : MonoBehaviour + { + [Inject] + int _value; + + public class Factory : Factory + { + } + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Fixture.cs.meta new file mode 100644 index 000000000..6c39a4f0f --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 515d1ac202f66014c980859ae924325a +timeCreated: 1459022928 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Foo.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Foo.cs new file mode 100644 index 000000000..f94a29301 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Foo.cs @@ -0,0 +1,20 @@ +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.TestBindFactory +{ + public interface IFoo + { + } + + public class IFooFactory : Factory + { + } + + public class Foo : MonoBehaviour, IFoo + { + public class Factory : Factory + { + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Foo.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Foo.cs.meta new file mode 100644 index 000000000..47b74fb30 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Foo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d2d5f4f0d25441b4b8dbdcf3e25815a4 +timeCreated: 1459026782 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources.meta new file mode 100644 index 000000000..53c16ebd0 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 04096944244ac8d4aa44abb732c12768 +folderAsset: yes +timeCreated: 1459032867 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory.meta new file mode 100644 index 000000000..c38c94b13 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 75a30b90ca91dde4aaf6c9044016a358 +folderAsset: yes +timeCreated: 1459032868 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/Foo.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/Foo.prefab new file mode 100644 index 000000000..29dd548a8 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/Foo.prefab @@ -0,0 +1,52 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &162430 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 447808} + - 114: {fileID: 11404662} + m_Layer: 0 + m_Name: Foo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &447808 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 162430} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11404662 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 162430} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d2d5f4f0d25441b4b8dbdcf3e25815a4, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 162430} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/Foo.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/Foo.prefab.meta new file mode 100644 index 000000000..6036d8a92 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/Foo.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1f6c6b0b26248ff40ab262d17954f3cd +timeCreated: 1459026819 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/FooSubContainer.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/FooSubContainer.prefab new file mode 100644 index 000000000..ced31b642 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/FooSubContainer.prefab @@ -0,0 +1,113 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &106024 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 432184} + - 114: {fileID: 11419678} + - 114: {fileID: 11408080} + m_Layer: 0 + m_Name: Foo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!1 &162430 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 447808} + - 114: {fileID: 11464440} + m_Layer: 0 + m_Name: FooSubContainer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &432184 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 106024} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 447808} + m_RootOrder: 0 +--- !u!4 &447808 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 162430} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: + - {fileID: 432184} + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11408080 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 106024} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0166d8ff8d905b048b2448179e1f5d11, type: 3} + m_Name: + m_EditorClassIdentifier: + _components: + - {fileID: 11419678} + _identifier: + _compositionRoot: {fileID: 0} + _bindType: 0 +--- !u!114 &11419678 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 106024} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: d2d5f4f0d25441b4b8dbdcf3e25815a4, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11464440 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 162430} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 08eca9f7688a0a24685b89133b020c8e, type: 3} + m_Name: + m_EditorClassIdentifier: + _installers: [] + _installerPrefabs: [] + _scriptableObjectInstallers: [] + _facade: {fileID: 0} +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 162430} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/FooSubContainer.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/FooSubContainer.prefab.meta new file mode 100644 index 000000000..3a4c78c2a --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/FooSubContainer.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5c4623f8776b50946bec4dd4e9b322e1 +timeCreated: 1460652820 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/TestTexture.png b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/TestTexture.png new file mode 100644 index 000000000..ae559b970 Binary files /dev/null and b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/TestTexture.png differ diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/TestTexture.png.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/TestTexture.png.meta new file mode 100644 index 000000000..d5b0c30c3 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/Resources/TestBindFactory/TestTexture.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: 7dd391639aa29ed45a73e9a214f4872c +timeCreated: 1459032868 +licenseType: Pro +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapMode: -1 + nPOTScale: 1 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaIsTransparency: 0 + textureType: -1 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/TestBindFactory.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/TestBindFactory.unity new file mode 100644 index 000000000..f65ae94ec --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/TestBindFactory.unity @@ -0,0 +1,158 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &978433746 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 978433749} + - 114: {fileID: 978433747} + - 114: {fileID: 978433750} + m_Layer: 0 + m_Name: SceneCompositionRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &978433747 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 978433750} + m_MethodName: TestToSubContainerPrefabResourceConcrete + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!4 &978433749 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &978433750 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 515d1ac202f66014c980859ae924325a, type: 3} + m_Name: + m_EditorClassIdentifier: + FooPrefab: {fileID: 162430, guid: 1f6c6b0b26248ff40ab262d17954f3cd, type: 2} + FooSubContainerPrefab: {fileID: 162430, guid: 5c4623f8776b50946bec4dd4e9b322e1, + type: 2} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/TestBindFactory.unity.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/TestBindFactory.unity.meta new file mode 100644 index 000000000..da347859b --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactory/TestBindFactory.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0299b7b8d0140174b98ab76935aa291f +timeCreated: 1459022928 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive.meta new file mode 100644 index 000000000..0a81549d5 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 53dcce6da2ccd0840bda6e58ee3b2cc5 +folderAsset: yes +timeCreated: 1460650158 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Fixture.cs new file mode 100644 index 000000000..85d7b6329 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Fixture.cs @@ -0,0 +1,185 @@ +using ModestTree.UnityUnitTester; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.TestBindFactoryFive +{ + public class Fixture : MonoTestFixture + { + public GameObject FooPrefab; + public GameObject FooSubContainerPrefab; + + [Test] + public void TestToGameObjectSelf() + { + Container.BindFactory().FromGameObject(); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToGameObjectConcrete() + { + Container.BindFactory().To().FromGameObject(); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToMonoBehaviourSelf() + { + var gameObject = Container.CreateEmptyGameObject("foo"); + + Container.BindFactory().FromComponent(gameObject); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToMonoBehaviourConcrete() + { + var gameObject = Container.CreateEmptyGameObject("foo"); + + Container.BindFactory().To().FromComponent(gameObject); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToPrefabSelf() + { + Container.BindFactory().FromPrefab(FooPrefab).WithGameObjectName("asdf"); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); + } + + [Test] + public void TestToPrefabConcrete() + { + Container.BindFactory().To().FromPrefab(FooPrefab).WithGameObjectName("asdf"); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); + } + + [Test] + public void TestToPrefabResourceSelf() + { + Container.BindFactory().FromPrefabResource("TestBindFactoryFive/Foo").WithGameObjectName("asdf"); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); + } + + [Test] + public void TestToPrefabResourceConcrete() + { + Container.BindFactory() + .To().FromPrefabResource("TestBindFactoryFive/Foo").WithGameObjectName("asdf"); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); + } + + [Test] + public void TestToSubContainerPrefabSelf() + { + Container.BindFactory() + .FromSubContainerResolve().ByPrefab(FooSubContainerPrefab); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToSubContainerPrefabConcrete() + { + Container.BindFactory() + .To().FromSubContainerResolve().ByPrefab(FooSubContainerPrefab); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToSubContainerPrefabResourceSelf() + { + Container.BindFactory().FromSubContainerResolve().ByPrefabResource("TestBindFactoryFive/FooSubContainer"); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToSubContainerPrefabResourceConcrete() + { + Container.BindFactory() + .To().FromSubContainerResolve().ByPrefabResource("TestBindFactoryFive/FooSubContainer"); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + void AddFactoryUser() + where TValue : IFoo + where TFactory : Factory + { + Container.Bind() + .To>().AsSingle(); + + Container.BindExecutionOrder>(-100); + } + + public class FooFactoryTester : IInitializable + where TFactory : Factory + where TValue : IFoo + { + readonly TFactory _factory; + + public FooFactoryTester(TFactory factory) + { + _factory = factory; + } + + public void Initialize() + { + Assert.IsEqual(_factory.Create(0.15, 0, 2.4f, "zxcv", 'z').Value, "zxcv"); + + Log.Info("Factory created foo successfully"); + } + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Fixture.cs.meta new file mode 100644 index 000000000..774eafb25 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: efc41e300d22c004785a433c1660c3d2 +timeCreated: 1460650180 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Foo.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Foo.cs new file mode 100644 index 000000000..fb486ec9d --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Foo.cs @@ -0,0 +1,36 @@ +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.TestBindFactoryFive +{ + public interface IFoo + { + string Value + { + get; + } + } + + public class IFooFactory : Factory + { + } + + public class Foo : MonoBehaviour, IFoo + { + [PostInject] + public void Init(double p1, int p2, float p3, string p4, char p5) + { + Value = p4; + } + + public string Value + { + get; + private set; + } + + public class Factory : Factory + { + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Foo.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Foo.cs.meta new file mode 100644 index 000000000..61897db82 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Foo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ee5b82f7221fdcb499856642f6436061 +timeCreated: 1460650180 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/FooInstaller.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/FooInstaller.cs new file mode 100644 index 000000000..8af526c96 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/FooInstaller.cs @@ -0,0 +1,35 @@ +using System; +using Zenject; + +namespace ModestTree.Tests.Zenject.TestBindFactoryFive +{ + public class FooInstaller : MonoInstaller + { + double _param1; + int _param2; + float _param3; + string _param4; + char _param5; + + [PostInject] + public void Init(double p1, int p2, float p3, string p4, char p5) + { + _param1 = p1; + _param2 = p2; + _param3 = p3; + _param4 = p4; + _param5 = p5; + } + + public override void InstallBindings() + { + Container.BindInstance(_param1).WhenInjectedInto(); + Container.BindInstance(_param2).WhenInjectedInto(); + Container.BindInstance(_param3).WhenInjectedInto(); + Container.BindInstance(_param4).WhenInjectedInto(); + Container.BindInstance(_param5).WhenInjectedInto(); + + Container.Bind().FromGameObject(); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/FooInstaller.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/FooInstaller.cs.meta new file mode 100644 index 000000000..c37f10e00 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/FooInstaller.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 90704beb7bb03b548a09a57bf84fd76a +timeCreated: 1460650180 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources.meta new file mode 100644 index 000000000..514b1a4f4 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 560835f4e49bbc24a919a5ac5e9dfd78 +folderAsset: yes +timeCreated: 1460650279 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive.meta new file mode 100644 index 000000000..434fe834a --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: cdc9bfa93df160f44a355be60a33e404 +folderAsset: yes +timeCreated: 1460650286 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive/Foo.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive/Foo.prefab new file mode 100644 index 000000000..9c4c199de --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive/Foo.prefab @@ -0,0 +1,52 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &115482 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 444256} + - 114: {fileID: 11480358} + m_Layer: 0 + m_Name: Foo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &444256 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 115482} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -37.141693, y: 4.1177154, z: 8.340115} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11480358 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 115482} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: ee5b82f7221fdcb499856642f6436061, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 115482} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive/Foo.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive/Foo.prefab.meta new file mode 100644 index 000000000..56608c026 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive/Foo.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 5c07ac3e518881e48885b91850c2f13c +timeCreated: 1460650304 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive/FooSubContainer.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive/FooSubContainer.prefab new file mode 100644 index 000000000..c0a54afcc --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive/FooSubContainer.prefab @@ -0,0 +1,69 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &136558 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 434280} + - 114: {fileID: 11447176} + - 114: {fileID: 11491928} + m_Layer: 0 + m_Name: FooSubContainer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &434280 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 136558} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: -37.141693, y: 4.1177154, z: 8.340115} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11447176 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 136558} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 08eca9f7688a0a24685b89133b020c8e, type: 3} + m_Name: + m_EditorClassIdentifier: + _installers: + - {fileID: 11491928} + _installerPrefabs: [] + _scriptableObjectInstallers: [] + _facade: {fileID: 0} +--- !u!114 &11491928 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 136558} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 90704beb7bb03b548a09a57bf84fd76a, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 136558} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive/FooSubContainer.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive/FooSubContainer.prefab.meta new file mode 100644 index 000000000..571f8d10b --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/Resources/TestBindFactoryFive/FooSubContainer.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ecdaaf4205a5c4046ae08fbe25f94e42 +timeCreated: 1460650324 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/TestBindFactoryFive.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/TestBindFactoryFive.unity new file mode 100644 index 000000000..6a65729fd --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/TestBindFactoryFive.unity @@ -0,0 +1,158 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &978433746 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 978433749} + - 114: {fileID: 978433747} + - 114: {fileID: 978433750} + m_Layer: 0 + m_Name: SceneCompositionRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &978433747 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 978433750} + m_MethodName: TestToSubContainerPrefabSelf + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!4 &978433749 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &978433750 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: efc41e300d22c004785a433c1660c3d2, type: 3} + m_Name: + m_EditorClassIdentifier: + FooPrefab: {fileID: 115482, guid: 5c07ac3e518881e48885b91850c2f13c, type: 2} + FooSubContainerPrefab: {fileID: 136558, guid: ecdaaf4205a5c4046ae08fbe25f94e42, + type: 2} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/TestBindFactoryFive.unity.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/TestBindFactoryFive.unity.meta new file mode 100644 index 000000000..f9c7a5715 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryFive/TestBindFactoryFive.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0092bba31a1115748bcfc96a90d03c46 +timeCreated: 1460650180 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne.meta new file mode 100644 index 000000000..cb49f7e75 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8dc97d13c0b4690458f0e3400cc375b9 +folderAsset: yes +timeCreated: 1459036969 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Fixture.cs new file mode 100644 index 000000000..0b402db4c --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Fixture.cs @@ -0,0 +1,184 @@ +using ModestTree.UnityUnitTester; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.TestBindFactoryOne +{ + public class Fixture : MonoTestFixture + { + public GameObject FooPrefab; + public GameObject FooSubContainerPrefab; + + [Test] + public void TestToGameObjectSelf() + { + Container.BindFactory().FromGameObject(); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToGameObjectConcrete() + { + Container.BindFactory().To().FromGameObject(); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToMonoBehaviourSelf() + { + var gameObject = Container.CreateEmptyGameObject("foo"); + + Container.BindFactory().FromComponent(gameObject); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToMonoBehaviourConcrete() + { + var gameObject = Container.CreateEmptyGameObject("foo"); + + Container.BindFactory().To().FromComponent(gameObject); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToPrefabSelf() + { + Container.BindFactory().FromPrefab(FooPrefab).WithGameObjectName("asdf"); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); + } + + [Test] + public void TestToPrefabConcrete() + { + Container.BindFactory().To().FromPrefab(FooPrefab).WithGameObjectName("asdf"); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); + } + + [Test] + public void TestToPrefabResourceSelf() + { + Container.BindFactory().FromPrefabResource("TestBindFactoryOne/Foo").WithGameObjectName("asdf"); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); + } + + [Test] + public void TestToPrefabResourceConcrete() + { + Container.BindFactory().To().FromPrefabResource("TestBindFactoryOne/Foo").WithGameObjectName("asdf"); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); + } + + [Test] + public void TestToSubContainerPrefabSelf() + { + Container.BindFactory().FromSubContainerResolve().ByPrefab(FooSubContainerPrefab); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToSubContainerPrefabConcrete() + { + Container.BindFactory() + .To().FromSubContainerResolve().ByPrefab(FooSubContainerPrefab); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToSubContainerPrefabResourceSelf() + { + Container.BindFactory() + .FromSubContainerResolve().ByPrefabResource("TestBindFactoryOne/FooSubContainer"); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + [Test] + public void TestToSubContainerPrefabResourceConcrete() + { + Container.BindFactory() + .To().FromSubContainerResolve().ByPrefabResource("TestBindFactoryOne/FooSubContainer"); + + AddFactoryUser(); + + FixtureUtil.AssertComponentCount(Container, 1); + FixtureUtil.AssertNumGameObjects(Container, 1); + } + + void AddFactoryUser() + where TValue : IFoo + where TFactory : Factory + { + Container.Bind() + .To>().AsSingle(); + + Container.BindExecutionOrder>(-100); + } + + public class FooFactoryTester : IInitializable + where TFactory : Factory + where TValue : IFoo + { + readonly TFactory _factory; + + public FooFactoryTester(TFactory factory) + { + _factory = factory; + } + + public void Initialize() + { + Assert.IsEqual(_factory.Create("asdf").Value, "asdf"); + + Log.Info("Factory created foo successfully"); + } + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Fixture.cs.meta new file mode 100644 index 000000000..ae95dee65 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 023811ddaa503dc4c8431d3cd3b69b6d +timeCreated: 1459036978 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Foo.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Foo.cs new file mode 100644 index 000000000..c161faf9b --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Foo.cs @@ -0,0 +1,36 @@ +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.TestBindFactoryOne +{ + public interface IFoo + { + string Value + { + get; + } + } + + public class IFooFactory : Factory + { + } + + public class Foo : MonoBehaviour, IFoo + { + [PostInject] + public void Init(string value) + { + Value = value; + } + + public string Value + { + get; + private set; + } + + public class Factory : Factory + { + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Foo.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Foo.cs.meta new file mode 100644 index 000000000..881ce71e5 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Foo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 01d5660ddd4f5d440a15f6ae003cd42a +timeCreated: 1459036978 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/FooInstaller.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/FooInstaller.cs new file mode 100644 index 000000000..ecb2c1930 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/FooInstaller.cs @@ -0,0 +1,22 @@ +using System; +using Zenject; + +namespace ModestTree.Tests.Zenject.TestBindFactoryOne +{ + public class FooInstaller : MonoInstaller + { + string _param1; + + [PostInject] + public void Init(string param1) + { + _param1 = param1; + } + + public override void InstallBindings() + { + Container.BindInstance(_param1).WhenInjectedInto(); + Container.Bind().FromGameObject(); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/FooInstaller.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/FooInstaller.cs.meta new file mode 100644 index 000000000..ff1bb1d0f --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/FooInstaller.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a4c5304e14d4ebf40a4d40c6c382964d +timeCreated: 1460646778 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources.meta new file mode 100644 index 000000000..1340f8854 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: fd54504068a2202498bcddcef5a1f406 +folderAsset: yes +timeCreated: 1459191999 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne.meta new file mode 100644 index 000000000..5009ca70e --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c3643fae8226ddd46a724c9ed954a2fe +folderAsset: yes +timeCreated: 1459192013 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne/Foo.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne/Foo.prefab new file mode 100644 index 000000000..a2623bece --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne/Foo.prefab @@ -0,0 +1,52 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &149814 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 416932} + - 114: {fileID: 11419076} + m_Layer: 0 + m_Name: Foo + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &416932 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 149814} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11419076 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 149814} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 01d5660ddd4f5d440a15f6ae003cd42a, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 149814} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne/Foo.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne/Foo.prefab.meta new file mode 100644 index 000000000..1280e469f --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne/Foo.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 95afbeacc839e0a4da5a6e116f07052e +timeCreated: 1459037082 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne/FooSubContainer.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne/FooSubContainer.prefab new file mode 100644 index 000000000..2776801dd --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne/FooSubContainer.prefab @@ -0,0 +1,69 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &149814 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 416932} + - 114: {fileID: 11494492} + - 114: {fileID: 11487118} + m_Layer: 0 + m_Name: FooSubContainer + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &416932 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 149814} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &11487118 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 149814} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: a4c5304e14d4ebf40a4d40c6c382964d, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!114 &11494492 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 149814} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 08eca9f7688a0a24685b89133b020c8e, type: 3} + m_Name: + m_EditorClassIdentifier: + _installers: + - {fileID: 11487118} + _installerPrefabs: [] + _scriptableObjectInstallers: [] + _facade: {fileID: 0} +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 149814} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne/FooSubContainer.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne/FooSubContainer.prefab.meta new file mode 100644 index 000000000..ec8503622 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/Resources/TestBindFactoryOne/FooSubContainer.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0465df6236950a740af6ead536450d8e +timeCreated: 1460646788 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/TestBindFactoryOne.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/TestBindFactoryOne.unity new file mode 100644 index 000000000..938235e5b --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/TestBindFactoryOne.unity @@ -0,0 +1,158 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &978433746 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 978433749} + - 114: {fileID: 978433747} + - 114: {fileID: 978433750} + m_Layer: 0 + m_Name: SceneCompositionRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &978433747 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 978433750} + m_MethodName: TestToSubContainerPrefabConcrete + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!4 &978433749 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &978433750 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 978433746} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 023811ddaa503dc4c8431d3cd3b69b6d, type: 3} + m_Name: + m_EditorClassIdentifier: + FooPrefab: {fileID: 149814, guid: 95afbeacc839e0a4da5a6e116f07052e, type: 2} + FooSubContainerPrefab: {fileID: 149814, guid: 0465df6236950a740af6ead536450d8e, + type: 2} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/TestBindFactoryOne.unity.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/TestBindFactoryOne.unity.meta new file mode 100644 index 000000000..c4bdcb831 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestBindFactoryOne/TestBindFactoryOne.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 2b525506a73e0064c8cf1663f636d916 +timeCreated: 1459036978 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory.meta new file mode 100644 index 000000000..a5206ff55 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 6c17648f7277132438673d4d8d4ba7fc +folderAsset: yes +timeCreated: 1459098627 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam.meta new file mode 100644 index 000000000..2bcd72e65 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: bfc0188eb3622674085014459289c2df +folderAsset: yes +timeCreated: 1459099456 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Fixture.cs new file mode 100644 index 000000000..38b190bca --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Fixture.cs @@ -0,0 +1,111 @@ +using ModestTree.UnityUnitTester; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.TestGameObjectFactory.OneParams +{ + public class Fixture : MonoTestFixture + { + public GameObject CubePrefab; + + const string GameObjName = "TestObj"; + + [Test] + public void TestPrefabSelfSingle1() + { + Container.BindFactory().FromPrefab(CubePrefab).WithGameObjectName(GameObjName); + + AddFactoryUser(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + } + + [Test] + public void TestPrefabConcreteSingle1() + { + Container.BindFactory().To().FromPrefab(CubePrefab).WithGameObjectName(GameObjName); + + AddFactoryUser(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + } + + [Test] + public void TestPrefabResourceSelfSingle1() + { + Container.BindFactory().FromPrefabResource("TestGameObjectFactoryOne/Cube").WithGameObjectName(GameObjName); + + AddFactoryUser(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + } + + [Test] + public void TestPrefabResourceConcreteSingle1() + { + Container.BindFactory().To().FromPrefabResource("TestGameObjectFactoryOne/Cube").WithGameObjectName(GameObjName); + + AddFactoryUser(); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + } + + void AddFactoryUser() + where T : IInitializable + { + Container.Bind().To().AsSingle(); + Container.BindExecutionOrder(-100); + } + + public class ObjectFactoryTester : IInitializable + { + readonly ObjectFactory _objectFactory; + + public ObjectFactoryTester(ObjectFactory objectFactory) + { + _objectFactory = objectFactory; + } + + public void Initialize() + { + var gameObject = (GameObject)_objectFactory.Create("asdf"); + + Assert.IsEqual(gameObject.GetComponentInChildren().Value, "asdf"); + + Log.Info("ObjectFactory initialized foo successfully"); + } + } + + public class CubeFactoryTester : IInitializable + { + readonly CubeFactory _cubeFactory; + + public CubeFactoryTester(CubeFactory cubeFactory) + { + _cubeFactory = cubeFactory; + } + + public void Initialize() + { + var gameObject = _cubeFactory.Create("asdf"); + + Assert.IsEqual(gameObject.GetComponentInChildren().Value, "asdf"); + + Log.Info("CubeFactory initialized foo successfully"); + } + } + + public class ObjectFactory : Factory + { + } + + public class CubeFactory : Factory + { + } + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Fixture.cs.meta new file mode 100644 index 000000000..61cefa84f --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: bcae9322877b14040a778629094879c6 +timeCreated: 1459214356 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Foo.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Foo.cs new file mode 100644 index 000000000..41985048b --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Foo.cs @@ -0,0 +1,20 @@ +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.TestGameObjectFactory.OneParams +{ + public class Foo : MonoBehaviour + { + [PostInject] + public void Init(string value) + { + Value = value; + } + + public string Value + { + get; + private set; + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Foo.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Foo.cs.meta new file mode 100644 index 000000000..5e06909e5 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Foo.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5424aef515984fd4da14e474c7ab463c +timeCreated: 1459214388 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Resources.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Resources.meta new file mode 100644 index 000000000..c1712627b --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 90633a898ea7b394b8404077f165b482 +folderAsset: yes +timeCreated: 1459214356 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Resources/TestGameObjectFactoryOne.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Resources/TestGameObjectFactoryOne.meta new file mode 100644 index 000000000..75c3caa3d --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Resources/TestGameObjectFactoryOne.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 058e96bc79a94844d8207b5a9c078dcc +folderAsset: yes +timeCreated: 1459214356 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Resources/TestGameObjectFactoryOne/Cube.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Resources/TestGameObjectFactoryOne/Cube.prefab new file mode 100644 index 000000000..a54ee9db3 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Resources/TestGameObjectFactoryOne/Cube.prefab @@ -0,0 +1,100 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &177174 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 452862} + - 33: {fileID: 3315238} + - 65: {fileID: 6519334} + - 23: {fileID: 2390420} + - 114: {fileID: 11443106} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &452862 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 177174} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!23 &2390420 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 177174} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 1 + m_ReflectionProbeUsage: 1 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!33 &3315238 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 177174} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!65 &6519334 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 177174} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &11443106 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 177174} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 5424aef515984fd4da14e474c7ab463c, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 177174} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Resources/TestGameObjectFactoryOne/Cube.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Resources/TestGameObjectFactoryOne/Cube.prefab.meta new file mode 100644 index 000000000..4c5937842 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/Resources/TestGameObjectFactoryOne/Cube.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3aca5d856f350b24eb622adb19746ebc +timeCreated: 1459214356 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/TestGameObjectFactoryOneParams.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/TestGameObjectFactoryOneParams.unity new file mode 100644 index 000000000..02137a462 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/TestGameObjectFactoryOneParams.unity @@ -0,0 +1,156 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &1653816974 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1653816976} + - 114: {fileID: 1653816977} + - 114: {fileID: 1653816978} + m_Layer: 0 + m_Name: SceneCompositionRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1653816976 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1653816974} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &1653816977 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1653816974} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1653816978} + m_MethodName: 5465737447616d654f626a65637453656c6631 + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: 556e697479456e67696e652e4f626a6563742c20556e697479456e67696e65 + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!114 &1653816978 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1653816974} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: bcae9322877b14040a778629094879c6, type: 3} + m_Name: + m_EditorClassIdentifier: + CubePrefab: {fileID: 177174, guid: 3aca5d856f350b24eb622adb19746ebc, type: 2} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/TestGameObjectFactoryOneParams.unity.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/TestGameObjectFactoryOneParams.unity.meta new file mode 100644 index 000000000..efa29085e --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/OneParam/TestGameObjectFactoryOneParams.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 10b39d81c26510b4f959b9f355299ff8 +timeCreated: 1459214356 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams.meta new file mode 100644 index 000000000..94669cbc3 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 21f63b9c9d6721e4e95140c7f2798930 +folderAsset: yes +timeCreated: 1459095274 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Fixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Fixture.cs new file mode 100644 index 000000000..24250c769 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Fixture.cs @@ -0,0 +1,90 @@ +using ModestTree.UnityUnitTester; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject.TestGameObjectFactory.ZeroParams +{ + public class Fixture : MonoTestFixture + { + public GameObject CubePrefab; + + const string GameObjName = "TestObj"; + + [Test] + public void TestGameObjectSelf1() + { + Container.BindFactory().FromGameObject().WithGameObjectName(GameObjName); + + FixtureUtil.CallFactoryCreateMethod(Container); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + } + + [Test] + public void TestGameObjectConcreteSingle() + { + Container.BindFactory().To().FromGameObject().WithGameObjectName(GameObjName); + + FixtureUtil.CallFactoryCreateMethod(Container); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + } + + [Test] + public void TestPrefabSelfSingle1() + { + Container.BindFactory().FromPrefab(CubePrefab).WithGameObjectName(GameObjName); + + FixtureUtil.CallFactoryCreateMethod(Container); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + } + + [Test] + public void TestPrefabConcreteSingle1() + { + Container.BindFactory().To().FromPrefab(CubePrefab).WithGameObjectName(GameObjName); + + FixtureUtil.CallFactoryCreateMethod(Container); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + } + + [Test] + public void TestPrefabResourceSelfSingle1() + { + Container.BindFactory() + .FromPrefabResource("BindGameObject/Cube").WithGameObjectName(GameObjName); + + FixtureUtil.CallFactoryCreateMethod(Container); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + } + + [Test] + public void TestPrefabResourceConcreteSingle1() + { + Container.BindFactory() + .To().FromPrefabResource("BindGameObject/Cube").WithGameObjectName(GameObjName); + + FixtureUtil.CallFactoryCreateMethod(Container); + + FixtureUtil.AssertNumGameObjects(Container, 1); + FixtureUtil.AssertNumGameObjectsWithName(Container, GameObjName, 1); + } + + public class ObjectFactory : Factory + { + } + + public class CubeFactory : Factory + { + } + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Fixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Fixture.cs.meta new file mode 100644 index 000000000..1e655616a --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Fixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0f24b347f46070f43b80467d7ab77003 +timeCreated: 1459095317 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Resources.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Resources.meta new file mode 100644 index 000000000..f4bc26b4d --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 610ff771a1e202e4f99f8eedc04e0bd6 +folderAsset: yes +timeCreated: 1459098362 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Resources/TestGameObjectFactory.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Resources/TestGameObjectFactory.meta new file mode 100644 index 000000000..30dc8f960 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Resources/TestGameObjectFactory.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 9a9e1871066bfbb4c924ceba8b2275a2 +folderAsset: yes +timeCreated: 1459098366 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Resources/TestGameObjectFactory/Cube.prefab b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Resources/TestGameObjectFactory/Cube.prefab new file mode 100644 index 000000000..ef4fdc045 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Resources/TestGameObjectFactory/Cube.prefab @@ -0,0 +1,88 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &177174 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 4 + m_Component: + - 4: {fileID: 452862} + - 33: {fileID: 3315238} + - 65: {fileID: 6519334} + - 23: {fileID: 2390420} + m_Layer: 0 + m_Name: Cube + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &452862 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 177174} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!23 &2390420 +MeshRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 177174} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_Materials: + - {fileID: 10303, guid: 0000000000000000f000000000000000, type: 0} + m_SubsetIndices: + m_StaticBatchRoot: {fileID: 0} + m_UseLightProbes: 1 + m_ReflectionProbeUsage: 1 + m_ProbeAnchor: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 1 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingOrder: 0 +--- !u!33 &3315238 +MeshFilter: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 177174} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} +--- !u!65 &6519334 +BoxCollider: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 177174} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 177174} + m_IsPrefabParent: 1 diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Resources/TestGameObjectFactory/Cube.prefab.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Resources/TestGameObjectFactory/Cube.prefab.meta new file mode 100644 index 000000000..9349e1761 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/Resources/TestGameObjectFactory/Cube.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 4fd68bd3734238e43bd8b8bc25db3bcf +timeCreated: 1459095429 +licenseType: Pro +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/TestGameObjectFactoryZeroParams.unity b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/TestGameObjectFactoryZeroParams.unity new file mode 100644 index 000000000..7ebefd529 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/TestGameObjectFactoryZeroParams.unity @@ -0,0 +1,156 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +SceneSettings: + m_ObjectHideFlags: 0 + m_PVSData: + m_PVSObjectsArray: [] + m_PVSPortalsArray: [] + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.212, g: 0.227, b: 0.259, a: 1} + m_AmbientEquatorColor: {r: 0.114, g: 0.125, b: 0.133, a: 1} + m_AmbientGroundColor: {r: 0.047, g: 0.043, b: 0.035, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 0 + m_SkyboxMaterial: {fileID: 10304, guid: 0000000000000000f000000000000000, type: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} +--- !u!157 &3 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 6 + m_GIWorkflowMode: 0 + m_LightmapsMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 1 + m_LightmapEditorSettings: + serializedVersion: 3 + m_Resolution: 2 + m_BakeResolution: 40 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AOMaxDistance: 1 + m_Padding: 2 + m_CompAOExponent: 0 + m_LightmapParameters: {fileID: 0} + m_TextureCompression: 1 + m_FinalGather: 0 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_LightingDataAsset: {fileID: 0} + m_RuntimeCPUUsage: 25 +--- !u!196 &4 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + accuratePlacement: 0 + minRegionArea: 2 + cellSize: 0.16666667 + manualCellSize: 0 + m_NavMeshData: {fileID: 0} +--- !u!1 &1653816974 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 4 + m_Component: + - 4: {fileID: 1653816976} + - 114: {fileID: 1653816977} + - 114: {fileID: 1653816978} + m_Layer: 0 + m_Name: SceneCompositionRoot + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1653816976 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1653816974} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 +--- !u!114 &1653816977 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1653816974} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0e516af87ca41694bbaa70c373f993e0, type: 3} + m_Name: + m_EditorClassIdentifier: + _runAll: 1 + _testMethod: + m_PersistentCalls: + m_Calls: + - m_Target: {fileID: 1653816978} + m_MethodName: 5465737447616d654f626a65637453656c6631 + m_Mode: 1 + m_Arguments: + m_ObjectArgument: {fileID: 0} + m_ObjectArgumentAssemblyTypeName: 556e697479456e67696e652e4f626a6563742c20556e697479456e67696e65 + m_IntArgument: 0 + m_FloatArgument: 0 + m_StringArgument: + m_BoolArgument: 0 + m_CallState: 1 + m_TypeName: UnityEngine.Events.UnityEvent, UnityEngine, Version=0.0.0.0, Culture=neutral, + PublicKeyToken=null +--- !u!114 &1653816978 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 1653816974} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 0f24b347f46070f43b80467d7ab77003, type: 3} + m_Name: + m_EditorClassIdentifier: + CubePrefab: {fileID: 177174, guid: 4fd68bd3734238e43bd8b8bc25db3bcf, type: 2} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/TestGameObjectFactoryZeroParams.unity.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/TestGameObjectFactoryZeroParams.unity.meta new file mode 100644 index 000000000..89a048e14 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Factories/TestGameObjectFactory/ZeroParams/TestGameObjectFactoryZeroParams.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 3eee376fc44bd264f8e7a1d69f0cbac5 +timeCreated: 1459095317 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner.meta new file mode 100644 index 000000000..d6655564c --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 5cc9453c60e642c439ba715c77a00456 +folderAsset: yes +timeCreated: 1462057592 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/MonoTestFixture.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/MonoTestFixture.cs new file mode 100644 index 000000000..b6dc8ee2b --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/MonoTestFixture.cs @@ -0,0 +1,16 @@ +using System; +using UnityEngine; +using Zenject; + +namespace ModestTree.UnityUnitTester +{ + public class MonoTestFixture : MonoBehaviour + { + public DiContainer Container + { + get; + set; + } + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/MonoTestFixture.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/MonoTestFixture.cs.meta new file mode 100644 index 000000000..15f4ff82d --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/MonoTestFixture.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 366fd48d2e243b44280ce5e0dab29938 +timeCreated: 1458225441 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/TestAttribute.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/TestAttribute.cs new file mode 100644 index 000000000..2b5e0cfa3 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/TestAttribute.cs @@ -0,0 +1,19 @@ +using System; + +namespace ModestTree.UnityUnitTester +{ + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + public class TestAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + public class ExpectedExceptionAttribute : Attribute + { + } + + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + public class ExpectedValidationExceptionAttribute : Attribute + { + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/TestAttribute.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/TestAttribute.cs.meta new file mode 100644 index 000000000..8289a690a --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/TestAttribute.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c67f0be581036284aae1205ecff23fcc +timeCreated: 1458225782 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestMultiRunner.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestMultiRunner.cs new file mode 100644 index 000000000..be145f89d --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestMultiRunner.cs @@ -0,0 +1,196 @@ + +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using ModestTree.Util; +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.SceneManagement; +using UnityEngine.Serialization; +using Zenject; + +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace ModestTree.UnityUnitTester +{ + public class UnityUnitTestMultiRunner : MonoBehaviour + { + [SerializeField] + [FormerlySerializedAs("_waitTime")] + public float WaitTime = 0.5f; + + bool _hitAnyError; + bool _suppressAllErrors; + bool _hasFailed; + + public void Start() + { + StartCoroutine(Run()); + ListenOnAllErrors(); + + Debug.Log("Starting UnityUnitTestMultiRunner..."); + } + + IEnumerator Run() + { + foreach (var fixture in GameObject.FindObjectsOfType()) + { + var testMethods = fixture.GetType().GetAllInstanceMethods() + .Where(x => x.GetCustomAttributes(typeof(TestAttribute), false).Any()); + + foreach (var methodInfo in testMethods) + { + yield return StartCoroutine(RunFixture(fixture, methodInfo, true)); + + if (_hasFailed) + { + break; + } + + yield return StartCoroutine(RunFixture(fixture, methodInfo, false)); + + if (_hasFailed) + { + break; + } + } + + if (_hasFailed) + { + break; + } + } + + if (_hasFailed) + { + Log.Error("Unity Unit Tests failed with errors"); + } + else + { + Log.Info("Unity Unit Tests passed successfully"); + } + +#if UNITY_EDITOR + EditorApplication.isPlaying = false; +#endif + } + + IEnumerator RunFixture(MonoTestFixture fixture, MethodInfo methodInfo, bool validateOnly) + { + // These should be reset each time + Assert.That(!_suppressAllErrors, "_suppressAllErrors is false"); + + bool isExpectingErrorDuringTest; + + if (validateOnly) + { + isExpectingErrorDuringTest = methodInfo.HasAttribute(); + } + else + { + isExpectingErrorDuringTest = methodInfo.HasAttribute(); + } + + var testName = "{0}.{1}".Fmt(fixture.GetType().Name(), methodInfo.Name); + + Log.Trace("{0} test '{1}'{2}", validateOnly ? "Validating" : "Running", testName, isExpectingErrorDuringTest ? "(expecting error)" : ""); + + var compRoot = SceneCompositionRoot.Create(); + + // Put under ourself otherwise it disables us during validation + compRoot.transform.parent = this.transform; + + compRoot.IsValidating = validateOnly; + compRoot.ValidateShutDownAfterwards = false; + + compRoot.NormalInstallers = new Installer[] + { + new ActionInstaller((container) => + { + fixture.Container = container; + methodInfo.Invoke(fixture, new object[0]); + container.FlushBindings(); + }) + }; + + compRoot.ParentNewObjectsUnderRoot = true; + + _hitAnyError = false; + _suppressAllErrors = isExpectingErrorDuringTest; + + try + { + compRoot.Run(); + } + catch (Exception e) + { + Debug.LogException(e); + } + + if (!validateOnly) + { + yield return new WaitForSeconds(WaitTime); + } + + _suppressAllErrors = false; + bool hitErrorDuringTest = _hitAnyError; + + GameObject.Destroy(compRoot.gameObject); + + yield return null; + + if (isExpectingErrorDuringTest) + { + if (hitErrorDuringTest) + { + Log.Trace("Hit expected error during test '{0}'. Ignoring.", testName); + } + else + { + Log.Error("Expected to hit error during test '{0}' but none was found!", testName); + _hasFailed = true; + } + } + else + { + if (hitErrorDuringTest) + { + _hasFailed = true; + } + } + } + + void ListenOnAllErrors() + { + Application.logMessageReceived += OnLogCallback; + } + + public void OnLogCallback(string message, string stackTrace, LogType logType) + { + if (logType == LogType.Assert || logType == LogType.Error || logType == LogType.Exception) + { + _hitAnyError = true; + } + } + + public class ActionInstaller : Installer + { + readonly Action _installMethod; + + public ActionInstaller(Action installMethod) + { + _installMethod = installMethod; + } + + public override void InstallBindings() + { + _installMethod(Container); + } + } + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestMultiRunner.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestMultiRunner.cs.meta new file mode 100644 index 000000000..9f79a874f --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestMultiRunner.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f3c1011000183804db9d595347f46d0a +timeCreated: 1461365344 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestRunner.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestRunner.cs new file mode 100644 index 000000000..0f5b19ddd --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestRunner.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using ModestTree.Util; +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.SceneManagement; +using UnityEngine.Serialization; +using Zenject; + +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace ModestTree.UnityUnitTester +{ + public class UnityUnitTestRunner : MonoBehaviour + { + [SerializeField] + bool _runAll; + + [SerializeField] + UnityEvent _testMethod; + + public void Awake() + { + if (_runAll) + { + gameObject.AddComponent(); + } + else + { + var installer = gameObject.AddComponent(); + installer.TestMethod = _testMethod; + + var compRoot = SceneCompositionRoot.CreateComponent(gameObject); + + compRoot.ParentNewObjectsUnderRoot = true; + + compRoot.Installers = new List() + { + installer + }; + + compRoot.Run(); + } + } + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestRunner.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestRunner.cs.meta new file mode 100644 index 000000000..87b0a0c4a --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestRunner.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0e516af87ca41694bbaa70c373f993e0 +timeCreated: 1461366294 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: -10100 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestSingleRunnerInstaller.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestSingleRunnerInstaller.cs new file mode 100644 index 000000000..8a00e7bbc --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestSingleRunnerInstaller.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using ModestTree.Util; +using UnityEngine; +using UnityEngine.Events; +using UnityEngine.SceneManagement; +using UnityEngine.Serialization; +using Zenject; + +#if UNITY_EDITOR +using UnityEditor; +#endif + +namespace ModestTree.UnityUnitTester +{ + public class UnityUnitTestSingleRunnerInstaller : MonoInstaller + { + [SerializeField] + float _waitTime = 0.5f; + + [SerializeField] + UnityEvent _testMethod; + + public UnityEvent TestMethod + { + get + { + return _testMethod; + } + set + { + _testMethod = value; + } + } + + public override void InstallBindings() + { + foreach (var fixture in GameObject.FindObjectsOfType()) + { + fixture.Container = Container; + } + + _testMethod.Invoke(); + + this.StartCoroutine(DelayThenPrintResult()); + } + + IEnumerator DelayThenPrintResult() + { + yield return new WaitForSeconds(_waitTime); + Log.Info("Completed running selected fixture"); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestSingleRunnerInstaller.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestSingleRunnerInstaller.cs.meta new file mode 100644 index 000000000..2b7f55df6 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Runner/UnityUnitTestSingleRunnerInstaller.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0c4d600a5e4385d41bbb17bea1fbbb35 +timeCreated: 1461366825 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util.meta new file mode 100644 index 000000000..504ea1b66 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c1a0f4d44afa2d04fa5df73418c6b98d +folderAsset: yes +timeCreated: 1462057592 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/ComponentCountAsserter.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/ComponentCountAsserter.cs new file mode 100644 index 000000000..e177b1557 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/ComponentCountAsserter.cs @@ -0,0 +1,32 @@ +using System; +using Zenject; +using UnityEngine; +using System.Linq; + +namespace ModestTree.Tests.Zenject +{ + public class ComponentCountAsserter : IInitializable + { + readonly int _expectedCount; + + public ComponentCountAsserter(int expectedCount) + { + _expectedCount = expectedCount; + } + + public void Initialize() + { + Assert.That(typeof(TComponent).DerivesFromOrEqual() || typeof(TComponent).IsAbstract); + + var num = GameObject.FindObjectsOfType() + .SelectMany(x => x.gameObject.GetComponents()).Count(); + + Assert.That(num == _expectedCount, + "Expected to find '{0}' components of type '{1}' but instead found '{2}'", + _expectedCount, typeof(TComponent).Name(), num); + + Log.Info("Correctly detected '{0}' components of type '{1}'", + _expectedCount, typeof(TComponent).Name()); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/ComponentCountAsserter.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/ComponentCountAsserter.cs.meta new file mode 100644 index 000000000..3c8ee59b7 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/ComponentCountAsserter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 5de18a1c5c657024c81001146ea032d0 +timeCreated: 1458929956 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/FactoryUser.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/FactoryUser.cs new file mode 100644 index 000000000..9a766b7ba --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/FactoryUser.cs @@ -0,0 +1,24 @@ +using System; +using Zenject; +using UnityEngine; +using System.Linq; + +namespace ModestTree.Tests.Zenject +{ + public class FactoryUser : IInitializable + where TFactory : Factory + { + readonly TFactory _factory; + + public FactoryUser(TFactory factory) + { + _factory = factory; + } + + public void Initialize() + { + Assert.IsNotNull(_factory.Create()); + } + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/FactoryUser.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/FactoryUser.cs.meta new file mode 100644 index 000000000..9b92b8d98 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/FactoryUser.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 42114fc6d3681b644846de2eaf1bad35 +timeCreated: 1459027439 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/FixtureUtil.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/FixtureUtil.cs new file mode 100644 index 000000000..a03bfa777 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/FixtureUtil.cs @@ -0,0 +1,67 @@ +using System; +using UnityEngine; +using Zenject; + +namespace ModestTree.Tests.Zenject +{ + public static class FixtureUtil + { + public static void AddInitMethod( + DiContainer container, Action method) + { + container.Bind() + .To().WithArguments(method); + } + + public static void AddInitMethod( + DiContainer container, Action method) + { + container.Bind() + .To>().WithArguments(method); + } + + public static void AddInitMethod( + DiContainer container, Action method) + { + container.Bind() + .To>().WithArguments(method); + } + + public static void AssertNumGameObjects( + DiContainer container, int expectedNumGameObjects) + { + container.Bind() + .To().WithArguments(expectedNumGameObjects); + } + + public static void AssertResolveCount( + DiContainer container, int expectedNum) + { + container.Bind() + .To>().WithArguments(expectedNum); + } + + public static void AssertComponentCount( + DiContainer container, int expectedNumComponents) + { + container.Bind() + .To>().WithArguments(expectedNumComponents); + } + + public static void AssertNumGameObjectsWithName( + DiContainer container, string name, int expectedNumGameObjects) + { + container.Bind() + .To().WithArguments(name, expectedNumGameObjects); + } + + public static void CallFactoryCreateMethod(DiContainer container) + where TFactory : Factory + { + container.Bind().To>().AsCached(); + + // Always create first so that you can use the asserts above + container.BindInitializableExecutionOrder>(-1); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/FixtureUtil.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/FixtureUtil.cs.meta new file mode 100644 index 000000000..4c4b65f68 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/FixtureUtil.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 68e0607803f00f24dbd0ef8c1085831a +timeCreated: 1458931511 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/GameObjectCountAsserter.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/GameObjectCountAsserter.cs new file mode 100644 index 000000000..7275a7e7a --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/GameObjectCountAsserter.cs @@ -0,0 +1,28 @@ +using System; +using Zenject; +using UnityEngine; + +namespace ModestTree.Tests.Zenject +{ + public class GameObjectCountAsserter : IInitializable + { + readonly GameObject _root; + readonly int _expectedCount; + + public GameObjectCountAsserter( + int expectedCount, + CompositionRoot root) + { + _root = root.gameObject; + _expectedCount = expectedCount; + } + + public void Initialize() + { + Assert.IsEqual(_root.transform.childCount, _expectedCount); + + Log.Info("Correctly detected '{0}' game objects", _expectedCount); + } + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/GameObjectCountAsserter.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/GameObjectCountAsserter.cs.meta new file mode 100644 index 000000000..a87730473 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/GameObjectCountAsserter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: bfd3203840ee08b4383f5054a5215071 +timeCreated: 1458930632 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/GameObjectNameCountAsserter.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/GameObjectNameCountAsserter.cs new file mode 100644 index 000000000..eb8eb94f1 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/GameObjectNameCountAsserter.cs @@ -0,0 +1,36 @@ +using System; +using Zenject; +using UnityEngine; +using System.Linq; + +namespace ModestTree.Tests.Zenject +{ + public class GameObjectNameCountAsserter : IInitializable + { + readonly GameObject _root; + readonly int _expectedCount; + readonly string _name; + + public GameObjectNameCountAsserter( + string name, + int expectedCount, + CompositionRoot root) + { + _name = name; + _root = root.gameObject; + _expectedCount = expectedCount; + } + + public void Initialize() + { + Assert.IsEqual( + _root.transform.Cast() + .Where(x => x.name == _name).Count(), + _expectedCount); + + Log.Info("Correctly detected '{0}' game objects with name '{1}'", _expectedCount, _name); + } + } +} + + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/GameObjectNameCountAsserter.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/GameObjectNameCountAsserter.cs.meta new file mode 100644 index 000000000..603e86e84 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/GameObjectNameCountAsserter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ec849ef57d75ecb4d86cb9173c70ac8b +timeCreated: 1458931511 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/InitMethodHandler.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/InitMethodHandler.cs new file mode 100644 index 000000000..2fc3cd090 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/InitMethodHandler.cs @@ -0,0 +1,61 @@ +using System; +using Zenject; + +namespace ModestTree.Tests.Zenject +{ + public class InitMethodHandler : IInitializable + { + readonly Action _method; + + public InitMethodHandler(Action method) + { + _method = method; + } + + public void Initialize() + { + _method(); + } + } + + public class InitMethodHandler : IInitializable + { + readonly TParam1 _param1; + readonly Action _method; + + public InitMethodHandler( + Action method, + TParam1 param1) + { + _param1 = param1; + _method = method; + } + + public void Initialize() + { + _method(_param1); + } + } + + public class InitMethodHandler : IInitializable + { + readonly TParam1 _param1; + readonly TParam2 _param2; + readonly Action _method; + + public InitMethodHandler( + Action method, + TParam1 param1, + TParam2 param2) + { + _param1 = param1; + _param2 = param2; + _method = method; + } + + public void Initialize() + { + _method(_param1, _param2); + } + } +} diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/InitMethodHandler.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/InitMethodHandler.cs.meta new file mode 100644 index 000000000..1fb1f9c3d --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/InitMethodHandler.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: a8f879495237a25449d35066397db5f4 +timeCreated: 1459207155 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/ResolveCountAsserter.cs b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/ResolveCountAsserter.cs new file mode 100644 index 000000000..64f58cde4 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/ResolveCountAsserter.cs @@ -0,0 +1,32 @@ +using System; +using Zenject; +using UnityEngine; +using System.Collections.Generic; + +namespace ModestTree.Tests.Zenject +{ + public class ResolveCountAsserter : IInitializable + { + readonly int _expectedCount; + readonly List _results; + + public ResolveCountAsserter( + [InjectOptional] + List results, + int expectedCount) + { + _results = results; + _expectedCount = expectedCount; + } + + public void Initialize() + { + Assert.That(_results.Count == _expectedCount, + "Expected to find '{0}' instances of type '{1}' but instead found '{2}'", + _expectedCount, typeof(TContract).Name(), _results.Count); + + Log.Info("Correctly resolved '{0}' objects with type '{1}'", _expectedCount, typeof(TContract).Name()); + } + } +} + diff --git a/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/ResolveCountAsserter.cs.meta b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/ResolveCountAsserter.cs.meta new file mode 100644 index 000000000..20d198016 --- /dev/null +++ b/UnityProject/Assets/Zenject/OptionalExtras/IntegrationTests/Util/ResolveCountAsserter.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2515245321de4e545bf652e19af813c7 +timeCreated: 1459008624 +licenseType: Pro +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: