public void ResolveType_Transient() { var helper = new UnityHelper(); var container = new UnityContainer(); container.RegisterType<ITestInterface, TestClass1>(new TransientLifetimeManager()); 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_ContainerWithoutTypeRegistered() { var helper = new UnityHelper(); var container = new UnityContainer(); ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => helper.ResolveType(container, typeof(ITestInterface))); }
public void ResolveType_InterfaceTypeNull() { var helper = new UnityHelper(); var container = new UnityContainer(); ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.ResolveType(container, null)); }
public void ResolveType_InvalidContainer() { var helper = new UnityHelper(); var container = new object(); ExceptionTester.CallMethodAndExpectException<NotSupportedException>(() => helper.ResolveType(container, typeof(ITestInterface))); }
public void ResolveType_ContainerNull() { var helper = new UnityHelper(); ExceptionTester.CallMethodAndExpectException<ArgumentNullException>(() => helper.ResolveType(null, typeof(ITestInterface))); }