Ejemplo n.º 1
0
        public void TestThatInjectingWorks()
        {
            IServiceProvider provider = new ServiceCollection()
                                        .AddSingleton <TestService>()
                                        .BuildServiceProvider();

            TestInjectable injectable = provider.Inject <TestInjectable>();

            Assert.NotNull(injectable.TestService);
        }
Ejemplo n.º 2
0
        public void Install()
        {
            Container.Bind <PrefabFactory>().AsTransient();
            _injectable      = new TestInjectable();
            _boundInjectable = new TestInjectable();
            Container.Bind <TestInjectable>().FromInstance(_boundInjectable).AsSingle();
            Container.Bind <PrefabFactoryTestObject>().FromResource(_testObjectPrefabPath).AsTransient();
            Container.Bind <GameObject>().FromResource(_simpleTestObjectPrefabPath).AsTransient();

            Container.Inject(this);
        }
Ejemplo n.º 3
0
        public void ShouldResolveComplexFuncCreator()
        {
            var injectedArg = new TestInjectable()
            {
                Id = 42
            };
            var sut     = _Context.Locator.Get <Func <IInjectable, TestFuncCreationComplex> >();
            var created = sut(injectedArg);

            Assert.IsTrue(created.InjectionTest.Id == 42);
        }
 private void Construct(TestInjectable injectable,
                        int number)
 {
     Injectable = injectable;
     Number     = number;
 }