示例#1
0
        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>()));
        }
示例#2
0
        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>()));
        }
示例#3
0
        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))));
        }
示例#4
0
        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);
        }