public void CanCreateOnePublicConstructorClassWithMultiPrivateConstructors() { var container = new InjectContainer(); var instance = container.Resolve<MultiplePrivateOnePublicConstructorClass>(); Assert.IsNotNull(instance); }
public void CanCreatePrivateNestedClass() { var container = new InjectContainer(); var instance = container.Resolve<PrivateClass>(); Assert.IsNotNull(instance); }
public void CannotResolveAbstractClass() { var container = new InjectContainer(); container.Register<IInterface1, AbstractClass1>(); Assert.That(() => container.Resolve<AbstractClass1>(), Throws.InstanceOf<ResolutionFailedException>()); }
public void CannotResolveInterface() { var container = new InjectContainer(); container.Register<IInterface1, IInherited1>(); Assert.That(() => container.Resolve<IInterface1>(), Throws.InstanceOf<ResolutionFailedException>()); }
public void CanCreateConcreteArgumentClass() { var container = new InjectContainer(); var instance = container.Resolve<ConcreteParameterClass>(); Assert.IsNotNull(instance); Assert.IsNotNull(instance.Arg); }
private static void GetServices() { var container = new InjectContainer(); container.Register <IMoleculeService, MoleculeService>(); container.Register <IMoleculeRepository, MoleculeRepository>(); container.Register <ILogService, LogService>(); container.Register <ILogRepository, LogRepository>(); container.Register <IAtomService, AtomService>(); container.Register <ILinkService, LinkService>(); container.Register <IReplacementReactionService, ReplacementReactionService>(); container.Register <IAddictionReactionService, AddictionReactionService>(); _moleculeService = container.Resolve <IMoleculeService>(); _linkService = container.Resolve <ILinkService>(); _logService = container.Resolve <ILogService>(); }
static void Main() { var container = new InjectContainer(); container.Register <IMoleculeService, MoleculeService>(); container.Register <IMoleculeRepository, MoleculeRepository>(); container.Register <ILogService, LogService>(); container.Register <ILogRepository, LogRepository>(); container.Register <IAtomService, AtomService>(); container.Register <ILinkService, LinkService>(); container.Register <IReplacementReactionService, ReplacementReactionService>(); container.Register <IAddictionReactionService, AddictionReactionService>(); var moleculeService = container.Resolve <IMoleculeService>(); var logService = container.Resolve <ILogService>(); var linkService = container.Resolve <ILinkService>(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MoleculeSearchForm(moleculeService, logService, linkService)); }
public void Initialize() { var container = new InjectContainer(); container.Register <IMoleculeService, MoleculeService>(); container.Register <IMoleculeRepository, MoleculeRepository>(); container.Register <ILogService, LogService>(); container.Register <ILogRepository, LogRepository>(); container.Register <IAtomService, AtomService>(); container.Register <ILinkService, LinkService>(); _linkService = container.Resolve <ILinkService>(); }
public void Initialize() { var container = new InjectContainer(); container.Register<IMoleculeService, MoleculeService>(); container.Register<IMoleculeRepository, MoleculeRepository>(); container.Register<ILogService, LogService>(); container.Register<ILogRepository, LogRepository>(); container.Register<IAtomService, AtomService>(); container.Register<ILinkService, LinkService>(); container.Register<IReplacementReactionService, ReplacementReactionService>(); container.Register<IAddictionReactionService, AddictionReactionService>(); _replacementReactionService = container.Resolve<IReplacementReactionService>(); }
public void ResolvesInstanceAsSingleton() { var container = new InjectContainer(); var instance = new Class1(); container.Register<IInterface1>(instance); var instance1 = container.Resolve<IInterface1>(); var instance2 = container.Resolve<IInterface1>(); Assert.AreSame(instance, instance1); Assert.AreSame(instance, instance2); }
public void CanResolveConcreteClassWithoutRegistering() { var container = new InjectContainer(); var instance = container.Resolve<Class1>(); Assert.IsNotNull(instance); }
public void CanRegisterTypeAsSingleton() { var container = new InjectContainer(); container.Register<IInterface1, Class1>(); var instance1 = container.Resolve<IInterface1>(); var instance2 = container.Resolve<IInterface1>(); Assert.AreSame(instance1, instance2); }
public void ResolveAbstractTypeThrows() { var container = new InjectContainer(); Assert.That(() => container.Resolve<AbstractClass1>(), Throws.InstanceOf<ResolutionFailedException>()); }
public void CreatingNoPublicConstructorClassThrows() { var container = new InjectContainer(); Assert.That(() => container.Resolve<NoConstructorClass>(), Throws.InstanceOf<ResolutionFailedException>()); }
public void ResolveCircularReferenceThrows() { var container = new InjectContainer(); container.Register<IInterface1, CircularReference1>(); container.Register<IInterface2, CircularReference2>(); Assert.That(() => container.Resolve<IInterface1>(), Throws.InstanceOf<ResolutionFailedException>()); }
public void ResolveNonConcreteTypeThrows() { var container = new InjectContainer(); Assert.That(() => container.Resolve<IInterface1>(), Throws.InstanceOf<ResolutionFailedException>()); }
public void ResolveStaticTypeThrows() { var container = new InjectContainer(); Assert.That(() => container.Resolve(typeof(StaticClass)), Throws.InstanceOf<ResolutionFailedException>()); }
public void ResolveNullTypeThrows() { var container = new InjectContainer(); Assert.That(() => container.Resolve(null), Throws.ArgumentNullException); }
public void ResolvesConstructorParameters() { var container = new InjectContainer(); container.Register<IInterfaceWithProperty, Class1WithProperty>(); container.Register<IInterface2, Class2>(); var instance = container.Resolve<IInterfaceWithProperty>(); Assert.IsNotNull(instance); Assert.IsNotNull(instance.Arg); }