public void Cannot_Resolve_Multiple_Implementation_WIthout_Attribute_From_Another_Assembly() { var manager = new ScannedTypeManager(); var type = manager.FindImplementationType(typeof(IMyExternalServiceC)); Assert.AreEqual(null, type); }
public void Resolve_ImplementationType_With_PreferredImplementation_Attribute_From_Another_Assembly() { var manager = new ScannedTypeManager(); var type = manager.FindImplementationType(typeof(IMyExternalServiceB)); Assert.AreEqual(typeof(MyExternalServiceB2), type); }
public void Cannot_Resolve_Multiple_Implementation_WIthout_Attribute() { var manager = new ScannedTypeManager(); var type = manager.FindImplementationType(typeof(IMyAwesomeServiceC)); Assert.AreEqual(null, type); }
public void Resolve_ImplementationType_With_PreferredImplementation_Attribute() { var manager = new ScannedTypeManager(); var type = manager.FindImplementationType(typeof(IMyAwesomeServiceB)); Assert.AreEqual(typeof(MyAwesomeServiceB2), type); }
public void Resolve_ImplementationType() { var manager = new ScannedTypeManager(); var type = manager.FindImplementationType(typeof(IMyAwesomeService)); Assert.AreEqual(typeof(MyAwesomeService), type); }
/// <summary> /// Creates the injector class. /// </summary> /// <param name="typeInformationManager">The type information manager</param> /// <param name="objectCreationManager">The object creation manager</param> /// <param name="singletonCache">The cache for singletons</param> /// <param name="scannedTypeManager">The scanned type manager</param> protected internal Injector(TypeInformationManager typeInformationManager, FactoryManager objectCreationManager, SingletonCache singletonCache, ScannedTypeManager scannedTypeManager) { if (typeInformationManager == null) { throw new ArgumentNullException(nameof(typeInformationManager)); } if (objectCreationManager == null) { throw new ArgumentNullException(nameof(objectCreationManager)); } if (singletonCache == null) { throw new ArgumentNullException(nameof(singletonCache)); } if (scannedTypeManager == null) { throw new ArgumentNullException(nameof(scannedTypeManager)); } registrations = new ConcurrentDictionary <Type, Dictionary <string, ContainerRegistration> >(); registered = new List <EventHandler <RegistrationEventArgs> >(); resolved = new List <EventHandler <ResolutionEventArgs> >(); this.lifetimeOnDiscovery = LifetimeOnDiscovery.Transcient; this.typeInformationManager = typeInformationManager; this.objectCreationManager = objectCreationManager; this.singletonCache = singletonCache; this.scannedTypeManager = scannedTypeManager; this.autoDiscovery = true; }
public void Cache_The_ImplementationType() { var manager = new ScannedTypeManager(); var type = manager.FindImplementationType(typeof(IMyAwesomeService)); Assert.AreEqual(typeof(MyAwesomeService), type); Assert.AreEqual(1, manager.ResolvedTypes.Count); Assert.AreEqual("MvvmLib.IoC.Tests.Scanned.IMyAwesomeService, MvvmLib.IoC.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", typeof(IMyAwesomeService).AssemblyQualifiedName); Assert.AreEqual(type, manager.ResolvedTypes[typeof(IMyAwesomeService).AssemblyQualifiedName]); var type2 = manager.FindImplementationType(typeof(IMyAwesomeService)); Assert.AreEqual(type2, type); }
public void Cache_The_Assembly() { var manager = new ScannedTypeManager(); Assert.AreEqual(0, manager.Assemblies.Count); var type = manager.FindImplementationType(typeof(IMyAwesomeService)); Assert.AreEqual(1, manager.Assemblies.Count); var a1 = manager.Assemblies.First(); manager.FindImplementationType(typeof(IMyAwesomeService)); Assert.AreEqual(1, manager.Assemblies.Count); manager.FindImplementationType(typeof(IMyExternalService)); Assert.AreEqual(2, manager.Assemblies.Count); }