public IEnumerator TestFromNewComponentOnNewGameObjectConcrete() { PreInstall(); Container.BindFactory <string, IFoo, IFooFactory>().To <Foo>().FromNewComponentOnNewGameObject(); AddFactoryUser <IFoo, IFooFactory>(); PostInstall(); FixtureUtil.AssertComponentCount <Foo>(1); FixtureUtil.AssertNumGameObjects(1); yield break; }
public void TestTransient() { var gameObject = Container.CreateEmptyGameObject("Foo"); Container.BindInstance(gameObject).WithId("Foo"); Container.Bind <Foo>().FromComponent(gameObject).AsTransient(); Container.Bind <IFoo>().To <Foo>().FromComponent(gameObject).AsTransient(); Container.BindRootResolve(new[] { typeof(IFoo), typeof(Foo) }); FixtureUtil.AssertComponentCount <Foo>(Container, 2); }
public void TestCached1() { var gameObject = Container.CreateEmptyGameObject("Foo"); Container.BindInstance(gameObject).WithId("Foo"); Container.Bind <Foo>().FromComponent(gameObject).AsCached(); Container.Bind <IFoo>().To <Foo>().FromComponent(gameObject).AsCached(); Container.BindRootResolve <IFoo>(); Container.BindRootResolve <Foo>(); FixtureUtil.AssertComponentCount <Foo>(Container, 2); }
public IEnumerator TestToSubContainerPrefabSelf() { PreInstall(); Container.BindFactory <Foo, Foo.Factory>().FromSubContainerResolve().ByNewContextPrefab(FooSubContainerPrefab); PostInstall(); FixtureUtil.CallFactoryCreateMethod <Foo, Foo.Factory>(Container); FixtureUtil.AssertComponentCount <Foo>(1); FixtureUtil.AssertNumGameObjects(1); yield break; }
public IEnumerator TestSelfCached() { PreInstall(); CommonInstall(); Container.Bind <Foo>().FromSubContainerResolve().ByNewPrefabResource(FooResourcePath).AsSingle().NonLazy(); PostInstall(); FixtureUtil.AssertNumGameObjects(1); FixtureUtil.AssertComponentCount <Foo>(1); yield break; }
public IEnumerator TestWithAbstractSearchMultipleMatch() { PreInstall(); // There are three components that implement INorf on this prefab Container.Bind <INorf>().FromComponentsInNewPrefab(NorfPrefab).AsCached().NonLazy(); PostInstall(); FixtureUtil.AssertNumGameObjects(1); FixtureUtil.AssertComponentCount <INorf>(3); FixtureUtil.AssertResolveCount <INorf>(Container, 3); yield break; }
public void TestToMonoBehaviourConcrete() { var gameObject = Container.CreateEmptyGameObject("foo"); Container.BindFactory <double, int, float, string, char, IFoo, IFooFactory>().To <Foo>().FromNewComponentOn(gameObject); AddFactoryUser <IFoo, IFooFactory>(); Initialize(); FixtureUtil.AssertComponentCount <Foo>(Container, 1); FixtureUtil.AssertNumGameObjects(Container, 1); }
public IEnumerator TestSelfIdentifiers() { PreInstall(); CommonInstall(); Container.Settings = new ZenjectSettings(ValidationErrorResponses.Throw); Container.Bind <Gorp>().FromSubContainerResolve("gorp").ByNewContextPrefab(FooPrefab).AsSingle().NonLazy(); PostInstall(); FixtureUtil.AssertNumGameObjects(1); yield break; }
public IEnumerator TestSelfTransient() { PreInstall(); CommonInstall(); Container.Bind <Foo>().FromSubContainerResolve().ByNewContextPrefab(FooPrefab).AsTransient().NonLazy(); PostInstall(); FixtureUtil.AssertNumGameObjects(1); FixtureUtil.AssertComponentCount <Foo>(1); yield break; }
public void TestToMonoBehaviourSelf() { var gameObject = Container.CreateEmptyGameObject("foo"); Container.BindFactory <string, Foo, Foo.Factory>().FromNewComponentOn(gameObject); AddFactoryUser <Foo, Foo.Factory>(); Initialize(); FixtureUtil.AssertComponentCount <Foo>(Container, 1); FixtureUtil.AssertNumGameObjects(Container, 1); }
public IEnumerator TestConcreteCached() { PreInstall(); CommonInstall(); Container.Bind <IFoo>().To <Foo>().FromSubContainerResolve().ByNewContextPrefab(FooPrefab).AsSingle().NonLazy(); PostInstall(); FixtureUtil.AssertNumGameObjects(1); FixtureUtil.AssertComponentCount <Foo>(1); yield break; }
public void TestToPrefabConcrete() { Container.BindFactory <string, IFoo, IFooFactory>().To <Foo>() .FromComponentInPrefab(FooPrefab).WithGameObjectName("asdf"); AddFactoryUser <IFoo, IFooFactory>(); Initialize(); FixtureUtil.AssertComponentCount <Foo>(Container, 1); FixtureUtil.AssertNumGameObjects(Container, 1); FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); }
public void TestFromNewComponentOnConcrete() { var gameObject = Container.CreateEmptyGameObject("foo"); Container.BindFactory <string, IFoo, IFooFactory>().To <Foo>().FromNewComponentOn(gameObject); AddFactoryUser <IFoo, IFooFactory>(); Initialize(); FixtureUtil.AssertComponentCount <Foo>(Container, 1); FixtureUtil.AssertNumGameObjects(Container, 1); }
public void TestUnderTransformGetter() { var tempGameObject = new GameObject("Foo"); Container.BindFactory <Foo, Foo.Factory>().FromNewComponentOnNewGameObject() .UnderTransform((context) => tempGameObject.transform); Initialize(); FixtureUtil.CallFactoryCreateMethod <Foo, Foo.Factory>(Container); Assert.IsNotNull(tempGameObject.transform.GetChild(0).GetComponent <Foo>()); }
// [TestCase("Java", ".java", "System.out.println(\"Inserted after.\");")] // [TestCase("JavaScript", ".js", "Console.log(\"Inserted after.\");")] // [TestCase("C", ".c", "printf(\"Inserted after.\");")] // [TestCase("CSharp", ".cs", "Console.WriteLine(\"Inserted after.\");")] // [TestCase("Python", ".py", "print \"Inserted after.\"")] public void CallAfterが正しく動作することを検証します(string language, string ext, string code) { var model = UnifiedGenerators.GenerateProgramFromFile( FixtureUtil.GetInputPath("Aspect", "Call", "Fibonacci" + ext)); var actual = UnifiedGenerators.GenerateProgramFromFile( FixtureUtil.GetInputPath("Aspect", "Call", "Fibonacci_expectation_after" + ext)); Call.InsertAtAfterCallByName( model, "fibonacci", UcoGenerator.CreateAdvice(language, code)); Assert.That(model, Is.EqualTo(actual).Using(StructuralEqualityComparer.Instance)); }
public void TestCached1() { Container.Bind <Foo>().FromNewComponentOnNewGameObject().WithGameObjectName(GameObjName).AsCached(); Container.Bind <IFoo>().To <Foo>().FromNewComponentOnNewGameObject().WithGameObjectName(GameObjName).AsCached(); Container.BindRootResolve <IFoo>(); Container.BindRootResolve <Foo>(); Initialize(); FixtureUtil.AssertNumGameObjects(Container, 2); FixtureUtil.AssertComponentCount <Foo>(Container, 2); }
public void WeavingAtBeforeCallAll() { var model = UnifiedGenerators.GenerateProgramFromFile(_studentPath); var actual = UnifiedGenerators.GenerateProgramFromFile(FixtureUtil.GetAopExpectationPath("Java", "Student_callBefore.java")); Call.InsertAtBeforeCallAll( model, UcoGenerator.CreateAdvice("Java", "Console.Write();")); Assert.That( model, Is.EqualTo(actual).Using(StructuralEqualityComparer.Instance)); }
public void TestMultipleConcreteTransient1() { Container.Bind <IFoo>().To(typeof(Foo), typeof(Bar)).FromNewComponentOnNewGameObject() .WithGameObjectName(GameObjName).AsTransient(); Container.BindRootResolve <IFoo>(); Initialize(); FixtureUtil.AssertNumGameObjects(Container, 2); FixtureUtil.AssertComponentCount <Foo>(Container, 1); FixtureUtil.AssertComponentCount <Bar>(Container, 1); }
public void TestToPrefabResourceConcrete() { Container.BindFactory <double, int, float, string, char, IFoo, IFooFactory>() .To <Foo>().FromComponentInPrefabResource("TestBindFactoryFive/Foo").WithGameObjectName("asdf"); AddFactoryUser <IFoo, IFooFactory>(); Initialize(); FixtureUtil.AssertComponentCount <Foo>(Container, 1); FixtureUtil.AssertNumGameObjects(Container, 1); FixtureUtil.AssertNumGameObjectsWithName(Container, "asdf", 1); }
public IEnumerator TestConcreteCachedMultipleContracts() { PreInstall(); CommonInstall(); Container.Bind(typeof(Foo), typeof(IFoo)).To <Foo>().FromSubContainerResolve().ByNewPrefabResource(FooResourcePath).AsSingle().NonLazy(); PostInstall(); FixtureUtil.AssertNumGameObjects(1); FixtureUtil.AssertComponentCount <Foo>(1); yield break; }
public IEnumerator TestFromNewComponentOnNewGameObjectWithParamsSuccess() { PreInstall(); Container.BindFactory <int, Foo2, Foo2.Factory2>().FromNewComponentOnNewGameObject(); PostInstall(); Container.Resolve <Foo2.Factory2>().Create(5); FixtureUtil.AssertComponentCount <Foo2>(1); FixtureUtil.AssertNumGameObjects(1); yield break; }
public IEnumerator TestTransient() { PreInstall(); Container.Bind <Foo>().FromComponentInNewPrefabResource(PathPrefix + "Foo").AsTransient(); Container.Bind <Foo>().FromComponentInNewPrefabResource(PathPrefix + "Foo").AsTransient(); Container.BindRootResolve <Foo>(); PostInstall(); FixtureUtil.AssertComponentCount <Foo>(2); yield break; }
public IEnumerator TestSelfIdentifiers() { PreInstall(); Container.Bind <Gorp>().FromSubContainerResolve("gorp").ByNewPrefab(FooPrefab).AsSingle(); Container.BindRootResolve <Gorp>(); Container.BindRootResolve <Gorp>(); PostInstall(); FixtureUtil.AssertNumGameObjects(1); yield break; }
public IEnumerator TestCached1() { PreInstall(); Container.Bind(typeof(Foo), typeof(Bar)).FromComponentInNewPrefabResource(PathPrefix + "Foo") .WithGameObjectName("Foo").AsCached().NonLazy(); PostInstall(); FixtureUtil.AssertNumGameObjects(1); FixtureUtil.AssertComponentCount <Foo>(1); FixtureUtil.AssertComponentCount <Bar>(1); FixtureUtil.AssertNumGameObjectsWithName("Foo", 1); yield break; }
public IEnumerator TestBasic() { PreInstall(); var gameObject = Container.CreateEmptyGameObject("Foo"); Container.BindInstance(gameObject).WithId("Foo"); Container.Bind <Foo>().FromNewComponentOn(gameObject).AsSingle().NonLazy(); PostInstall(); FixtureUtil.AssertComponentCount <Foo>(1); yield break; }
public IEnumerator TestSingleIdentifiers() { PreInstall(); Container.Bind <Foo>().FromComponentInNewPrefabResource(PathPrefix + "Foo").WithGameObjectName("Foo").AsSingle().NonLazy(); Container.Bind <Bar>().FromComponentInNewPrefabResource(PathPrefix + "Foo").WithGameObjectName("Foo").AsSingle().NonLazy(); PostInstall(); FixtureUtil.AssertNumGameObjects(1); FixtureUtil.AssertComponentCount <Foo>(1); FixtureUtil.AssertComponentCount <Bar>(1); FixtureUtil.AssertNumGameObjectsWithName("Foo", 1); yield break; }
public IEnumerator TestSingle2() { PreInstall(); // For ToPrefab, the 'AsSingle' applies to the prefab and not the type, so this is valid Container.Bind <IFoo>().To <Foo>().FromComponentInNewPrefabResource(PathPrefix + "Foo").AsSingle().NonLazy(); Container.Bind <Foo>().FromComponentInNewPrefabResource(PathPrefix + "Foo2").AsSingle().NonLazy(); Container.Bind <Foo>().FromMethod(ctx => ctx.Container.CreateEmptyGameObject("Foo").AddComponent <Foo>()).NonLazy(); PostInstall(); FixtureUtil.AssertComponentCount <Foo>(3); FixtureUtil.AssertNumGameObjects(3); yield break; }
public IEnumerator TestWithAbstractSearch() { PreInstall(); // There are three components that implement INorf on this prefab // and so this should result in a list of 3 INorf's Container.Bind <INorf>().FromComponentInNewPrefabResource(PathPrefix + "Norf").AsTransient().NonLazy(); PostInstall(); FixtureUtil.AssertNumGameObjects(1); FixtureUtil.AssertComponentCount <INorf>(3); FixtureUtil.AssertResolveCount <INorf>(Container, 3); yield break; }
public IEnumerator TestWithArguments() { PreInstall(); Container.Bind(typeof(Gorp)) .FromComponentInNewPrefabResource(PathPrefix + "Gorp").WithGameObjectName("Gorp").AsCached() .WithArguments("test1").NonLazy(); PostInstall(); FixtureUtil.AssertNumGameObjects(1); FixtureUtil.AssertComponentCount <Gorp>(1); FixtureUtil.AssertNumGameObjectsWithName("Gorp", 1); yield break; }
public void TestSelfSingle() { Container.Bind <Foo>().FromSubContainerResolve() .ByPrefab(FooPrefab).AsSingle(); Container.BindRootResolve <Foo>(); Container.BindRootResolve <Foo>(); Container.BindRootResolve <Foo>(); Initialize(); FixtureUtil.AssertNumGameObjects(Container, 1); FixtureUtil.AssertComponentCount <Foo>(Container, 1); }