public TConfiguration Create <TConfiguration>() { _scopedObjects = new Dictionary <Type, object>(); var configurationType = typeof(TConfiguration); if (_configuration.IsConfigured(configurationType)) { var injectionSpecification = _configuration.GetInjectionSpecification(configurationType); return((TConfiguration)Create(injectionSpecification)); } throw new ArgumentException($"Type is not configured: ${typeof(TConfiguration)}"); }
public void GivenCreate_WhenConfigurationStyleIsNone_ThenCreatesClass() { var configurationType = typeof(IBasicClass); var injection = new InjectionSpecification { ConfigurationType = configurationType, ConfigurationStyle = ConfigurationStyle.None }; A.CallTo(() => _mockConfiguration.IsConfigured(configurationType)).Returns(true); A.CallTo(() => _mockConfiguration.GetInjectionSpecification(configurationType)).Returns(injection); var dependencyInjector = new DependencyInjector(_mockConfiguration); Assert.Throws <ArgumentException>(() => dependencyInjector.Create <IBasicClass>()); }
public void GivenIsConfigured_WhenInterfaceNotConfigured_ThenReturnFalse() { Assert.False(_target.IsConfigured(typeof(IBasicClass))); }