public void ResolveAllOnlyReturnsInterfaceRegistrations() { ITest iTest; ATest objA = new ATest(); BTest objB = new BTest(); CTest objC = new CTest(); objA.Strtest = "Hi"; UnityContainer uc1 = new UnityContainer(); uc1.RegisterType <ITest, ATest>(); iTest = objA; uc1.RegisterInstance("ATest", iTest); iTest = objB; uc1.RegisterInstance("BTest", iTest); iTest = objC; uc1.RegisterInstance("CTest", iTest); List <ATest> list = new List <ATest>(uc1.ResolveAll <ATest>()); List <ITest> list3 = new List <ITest>(uc1.ResolveAll <ITest>()); Assert.AreEqual(0, list.Count); Assert.AreEqual(3, list3.Count); }
public void ResolveAllOnlyReturnsInterfaceRegistrations() { ITest iTest; ATest objA = new ATest(); BTest objB = new BTest(); CTest objC = new CTest(); objA.Strtest = "Hi"; UnityContainer uc1 = new UnityContainer(); uc1.RegisterType<ITest, ATest>(); iTest = objA; uc1.RegisterInstance("ATest", iTest); iTest = objB; uc1.RegisterInstance("BTest", iTest); iTest = objC; uc1.RegisterInstance("CTest", iTest); List<ATest> list = new List<ATest>(uc1.ResolveAll<ATest>()); List<ITest> list3 = new List<ITest>(uc1.ResolveAll<ITest>()); Assert.AreEqual(0, list.Count); Assert.AreEqual(3, list3.Count); }
public void NamedMappedInterfaceInstanceRegistrationCanBeResolved() { ITest iTest; ATest objA = null; UnityContainer uc1 = new UnityContainer(); iTest = objA; uc1.RegisterInstance <ITest>("ATest", new ATest()); iTest = (ITest)uc1.Resolve(typeof(ITest), "ATest"); Assert.IsNotNull(iTest); }
public void UnnamedMappingThrowsResolutionFailedException() { //The inner exception says {"The type ITest does not have an accessible constructor."} where as it should //specify that the named registration for ITest does not exist //There is an unnamed mapping ATest objA = null; UnityContainer uc1 = new UnityContainer(); uc1.RegisterType <ITest, ATest>(); AssertHelper.ThrowsException <ResolutionFailedException>(() => objA = (ATest)uc1.Resolve <ITest>("ATest")); }
public ArrParameter(ATest[] i) { }