Example #1
0
 public static void explicitGenerator()
 {
     var b = new Konstruktor();
     b.registerGenerator<IGeneratorExample>(scope => new GeneratorExample());
     using (var s = b.beginScope())
     {
         var generated = s.resolve<IGeneratorExample>();
         Assert.AreEqual(typeof (GeneratorExample), generated.GetType());
     }
 }
Example #2
0
        public void testImplementationGenerator()
        {
            var builder = new Konstruktor();
            builder.registerGenerator(s => new Implementation());

            using (var scope = builder.beginScope())
            {
                var dummy = scope.resolve<Implementation>();
                Assert.AreEqual(typeof(Implementation), dummy.GetType());
            }
        }
Example #3
0
        public static void explicitGenerator()
        {
            var b = new Konstruktor();

            b.registerGenerator <IGeneratorExample>(scope => new GeneratorExample());
            using (var s = b.beginScope())
            {
                var generated = s.resolve <IGeneratorExample>();
                Assert.AreEqual(typeof(GeneratorExample), generated.GetType());
            }
        }
Example #4
0
        public void testImplementationGenerator()
        {
            var builder = new Konstruktor();

            builder.registerGenerator(s => new Implementation());

            using (var scope = builder.beginScope())
            {
                var dummy = scope.resolve <Implementation>();
                Assert.AreEqual(typeof(Implementation), dummy.GetType());
            }
        }
Example #5
0
        public static void explicitGeneratorPropertyInjection()
        {
            var b = new Konstruktor();
            b.registerGenerator(scope => new PropertyInjection {Generator = scope.resolve<GeneratorExample>()});

            using (var s = b.beginScope())
            {
                var generated = s.resolve<PropertyInjection>();
                Assert.AreEqual(typeof(PropertyInjection), generated.GetType());
                Assert.AreNotEqual(null, generated.Generator);
            }
        }
Example #6
0
        public static void explicitGeneratorPropertyInjection()
        {
            var b = new Konstruktor();

            b.registerGenerator(scope => new PropertyInjection {
                Generator = scope.resolve <GeneratorExample>()
            });

            using (var s = b.beginScope())
            {
                var generated = s.resolve <PropertyInjection>();
                Assert.AreEqual(typeof(PropertyInjection), generated.GetType());
                Assert.AreNotEqual(null, generated.Generator);
            }
        }