public void ResolveType_Transient() { var helper = new NinjectHelper(); var container = new StandardKernel(); container.Bind(typeof(ITestInterface)).To <TestClass1>().InTransientScope(); var resolvedInstance1 = helper.ResolveType(container, typeof(ITestInterface)); Assert.IsNotNull(resolvedInstance1); Assert.IsInstanceOfType(resolvedInstance1, typeof(TestClass1)); var resolvedInstance2 = helper.ResolveType(container, typeof(ITestInterface)); Assert.IsNotNull(resolvedInstance2); Assert.IsInstanceOfType(resolvedInstance2, typeof(TestClass1)); Assert.IsFalse(ReferenceEquals(resolvedInstance1, resolvedInstance2)); }
public void ResolveType_ContainerWithTypeRegistered() { var helper = new NinjectHelper(); var container = new StandardKernel(); container.Bind(typeof(ITestInterface)).To <TestClass1>(); var resolvedInstance = helper.ResolveType(container, typeof(ITestInterface)); Assert.IsNotNull(resolvedInstance); Assert.IsInstanceOfType(resolvedInstance, typeof(TestClass1)); }
public void ResolveType_ContainerWithoutTypeRegistered() { var helper = new NinjectHelper(); var container = new StandardKernel(); ExceptionTester.CallMethodAndExpectException <NotSupportedException>(() => helper.ResolveType(container, typeof(ITestInterface))); }
public void ResolveType_InvalidContainer() { var helper = new NinjectHelper(); var container = new object(); ExceptionTester.CallMethodAndExpectException <NotSupportedException>(() => helper.ResolveType(container, typeof(ITestInterface))); }
public void ResolveType_InterfaceTypeNull() { var helper = new NinjectHelper(); var container = new StandardKernel(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.ResolveType(container, null)); }
public void ResolveType_ContainerNull() { var helper = new NinjectHelper(); ExceptionTester.CallMethodAndExpectException <ArgumentNullException>(() => helper.ResolveType(null, typeof(ITestInterface))); }