public void InvalidDependencyTypeTest() { var constructor = new TypeDependencyConstructor(); Assert.Throws <InvalidOperationException>(() => constructor.Construct( GetType(), Mock.Of <IDependency>(), new Dictionary <Type, Action <ILGenerator> >(), new Dictionary <Type, IDependency>(), new Stack <Type>())); }
public void DependencyWithMissingReferenceTest() { var constructor = new TypeDependencyConstructor(); var dependency = new TypeDependency(typeof(DependentService), new Dictionary <Type, IDependency>()); Assert.Throws <NotImplementedException>(() => constructor.Construct( dependency.OriginalType, dependency, new Dictionary <Type, Action <ILGenerator> >(), new Dictionary <Type, IDependency>(), new Stack <Type>())); }
public void RecursiveDependencyTest() { var constructor = new TypeDependencyConstructor(); var dependency = new TypeDependency(GetType(), new Dictionary <Type, IDependency>()); dependency.SetServiceType <TypeDependencyConstructorTests>(); Assert.Throws <InvalidOperationException>(() => constructor.Construct( dependency.OriginalType, dependency, new Dictionary <Type, Action <ILGenerator> >(), new Dictionary <Type, IDependency>(), new Stack <Type>(Enumerable.Repeat(GetType(), 1)))); }
public void DependencyWithDefaultConstructorTest() { var constructor = new TypeDependencyConstructor(); var dependency = new TypeDependency(typeof(PlainService), new Dictionary <Type, IDependency>()); var knownTypes = new Dictionary <Type, Action <ILGenerator> >(); var action = constructor.Construct( dependency.OriginalType, dependency, knownTypes, new Dictionary <Type, IDependency>(), new Stack <Type>()); Assert.IsNotEmpty(knownTypes); AssertIlValidity(action, dependency.OriginalType); }