Ejemplo n.º 1
0
 public void CreateNew_WrongNumberOfArgs()
 {
     Assert.Throws <ApplicationException>(() => {
         var result = InstantiatorCache.Get <PublicConstructors>(typeof(int)).New();
     });
     Assert.Throws <ApplicationException>(() => {
         var result = InstantiatorCache.Get <PublicConstructors>().New(7);
     });
 }
Ejemplo n.º 2
0
        public void CreateNew()
        {
            void check(ITestConstructor normal, ITestConstructor reflection)
            {
                Assert.Equal(normal.a, reflection.a);
                Assert.Equal(normal.b, reflection.b);
            }

            check(new PublicConstructors(), InstantiatorCache.Get <PublicConstructors>().New());
            check(new PublicConstructors(7), InstantiatorCache.Get <PublicConstructors>(typeof(int)).New(7));
            check(new PublicConstructors(8, "nine"), InstantiatorCache.Get <PublicConstructors>(typeof(int), typeof(string)).New(8, "nine"));

            check(new PublicConstructors(), InstantiatorCache.Get <PrivateConstructors>().New());
            check(new PublicConstructors(7), InstantiatorCache.Get <PrivateConstructors>(typeof(int)).New(7));
            check(new PublicConstructors(8, "nine"), InstantiatorCache.Get <PrivateConstructors>(typeof(int), typeof(string)).New(8, "nine"));
        }
Ejemplo n.º 3
0
 public void CreateNew_WrongTypes()
 {
     Assert.Throws <InvalidCastException>(() => {
         var result = InstantiatorCache.Get <PublicConstructors>(typeof(int)).New((double)2.2);
     });
 }
Ejemplo n.º 4
0
 public void CreateNew_NoMatchingConstructor()
 {
     Assert.Throws <ApplicationException>(() => {
         var result = InstantiatorCache.Get <PublicConstructors>(typeof(double)).New((double)2.2);
     });
 }