public void ResolveWithNamedParamsTest() { var registerResolver = new OrlemContainer(new LoggingService()); registerResolver.Register <ITestSingletone, TestSingletone>(); registerResolver.Start(); var service = registerResolver.Resolve <ITestSingletone>(); Assert.IsNotNull(service); service.TestProperty = 99; var target = registerResolver.Resolve <CustomParametersTarget2>( new ResolveParameter { ParameterName = "stringParam", Parameter = "qwerty" }, new ResolveParameter { ParameterName = "intParam2", Parameter = 44 }, new ResolveParameter { ParameterName = "intParam", Parameter = 33 }); Assert.IsNotNull(target); Assert.IsNotNull(target.InjectedService); Assert.AreEqual(99, target.InjectedService.TestProperty); Assert.AreEqual("qwerty", target.StringFromParam); Assert.AreEqual(33, target.IntFromParam); Assert.AreEqual(44, target.IntFromParam2); }
public void InjectionTest() { var registerResolver = new OrlemContainer(new LoggingService()); registerResolver.Register <ITestSingletone, TestSingletone>(); registerResolver.Register <IInjectionTarget, InjectionTarget>(); registerResolver.Start(); var service = registerResolver.Resolve <ITestSingletone>(); Assert.IsNotNull(service); service.TestProperty = 99; var target = registerResolver.Resolve <IInjectionTarget>(); Assert.IsNotNull(target); Assert.IsNotNull(target.InjectedService); Assert.AreEqual(99, target.InjectedService.TestProperty); }
public void ResolveTest() { var registerResolver = new OrlemContainer(new LoggingService()); registerResolver.Register <ITestService, TestService>(); registerResolver.Start(); var service = registerResolver.Resolve <ITestService>(); Assert.IsNotNull(service); }
public void GenericsTest() { var registerResolver = new OrlemContainer(new LoggingService()); registerResolver.Register(typeof(IGenericService <>), typeof(GenericService <>)); registerResolver.Start(); var service1 = registerResolver.Resolve <IGenericService <string> >(); var service2 = registerResolver.Resolve <IGenericService <int> >(); Assert.IsNotNull(service1); Assert.IsNotNull(service2); Assert.IsNull(service1.GenericProperty); Assert.AreEqual(0, service2.GenericProperty); }
public void SingletoneTest() { var registerResolver = new OrlemContainer(new LoggingService()); registerResolver.Register <ITestSingletone, TestSingletone>(); registerResolver.Start(); var service = registerResolver.Resolve <ITestSingletone>(); Assert.IsNotNull(service); service.TestProperty = 99; var service2 = registerResolver.Resolve <ITestSingletone>(); Assert.IsNotNull(service2); Assert.AreEqual(99, service2.TestProperty); }
public void ResolveWithParamsTest() { var registerResolver = new OrlemContainer(new LoggingService()); registerResolver.Register <ITestSingletone, TestSingletone>(); registerResolver.Start(); var service = registerResolver.Resolve <ITestSingletone>(); Assert.IsNotNull(service); service.TestProperty = 99; var target = registerResolver.Resolve <CustomParametersTarget>("abc", 22); Assert.IsNotNull(target); Assert.IsNotNull(target.InjectedService); Assert.AreEqual(99, target.InjectedService.TestProperty); Assert.AreEqual("abc", target.StringFromParam); Assert.AreEqual(22, target.IntFromParam); }