public void TestThatInjectingWorks() { IServiceProvider provider = new ServiceCollection() .AddSingleton <TestService>() .BuildServiceProvider(); TestInjectable injectable = provider.Inject <TestInjectable>(); Assert.NotNull(injectable.TestService); }
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); }
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; }