public IEnumerator TestBadResourcePath()
 {
     PreInstall();
     Assert.Throws(() => FooInstaller.InstallFromResource("TestScriptableObjectInstallers/SDFSDFSDF", Container));
     PostInstall();
     yield break;
 }
Example #2
0
        public void TestZeroArgs()
        {
            FooInstaller.Install(Container);

            Initialize();

            FixtureUtil.AssertResolveCount <Foo>(Container, 1);
        }
Example #3
0
        public void TestZeroArgs()
        {
            FooInstaller.InstallFromResource("TestScriptableObjectInstallers/FooInstaller", Container);

            Initialize();

            FixtureUtil.AssertResolveCount <Foo>(Container, 1);
        }
        public IEnumerator TestZeroArgs()
        {
            PreInstall();
            FooInstaller.InstallFromResource("TestScriptableObjectInstallers/FooInstaller", Container);

            PostInstall();

            FixtureUtil.AssertResolveCount <Foo>(Container, 1);
            yield break;
        }
        public IEnumerator TestZeroArgs()
        {
            PreInstall();
            FooInstaller.Install(Container);

            PostInstall();

            FixtureUtil.AssertResolveCount <Foo>(Container, 1);
            yield break;
        }
Example #6
0
        void InstallMore4()
        {
            ///////////// Installing Other Installers

            // Immediately call InstallBindings() on FooInstaller
            FooInstaller.Install(Container);

            // Before calling FooInstaller, configure a property of it
            Container.BindInstance("foo").WhenInjectedInto <FooInstaller>();
            FooInstaller.Install(Container);

            // The arguments can also be added to the Installer<> generic arguments to make them
            // strongly typed
            FooInstallerWithArgs.Install(Container, "foo");

            ///////////// Manual Use of Container

            // This will fill in any parameters marked as [Inject] and also call any [Inject] methods
            Foo foo = new Foo();

            Container.Inject(foo);

            // Return an instance for IFoo, using the bindings that have been added previously
            // Internally it is what is triggered when you fill in a constructor parameter of type IFoo
            // Note: It will throw an exception if it cannot find a match
            Container.Resolve <IFoo>();

            // Same as the above except returns null when it can't find the given type
            Container.TryResolve <IFoo>();

            // Return a list of 2 instances of type Foo
            // Note that in this case simply calling Resolve<IFoo> will trigger an exception
            Container.BindInstance(new Foo());
            Container.BindInstance(new Foo());
            System.Collections.Generic.List <IFoo> foos = Container.ResolveAll <IFoo>();

            // Create a new instance of Foo and inject on any of its members
            // And fill in any constructor parameters Foo might have
            Container.Instantiate <Foo>();

            GameObject prefab1 = null;
            GameObject prefab2 = null;

            // Instantiate a new prefab and have any injectables filled in on the prefab
            GameObject go = Container.InstantiatePrefab(prefab1);

            // Instantiate a new prefab and return a specific monobehaviour
            Foo foo2 = Container.InstantiatePrefabForComponent <Foo>(prefab2);

            // Add a new component to an existing game object
            Foo foo3 = Container.InstantiateComponent <Foo>(go);
        }
Example #7
0
 public void TestBadResourcePath()
 {
     Assert.Throws(() => FooInstaller.InstallFromResource("TestScriptableObjectInstallers/SDFSDFSDF", Container));
     Initialize();
 }
Example #8
0
 public void TestBadResourcePath()
 {
     FooInstaller.InstallFromResource("TestMonoInstallers/SDFSDFSDF", Container);
     Initialize();
 }