示例#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);
     });
 }
示例#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"));
        }
示例#3
0
 public void CreateNew_WrongTypes()
 {
     Assert.Throws <InvalidCastException>(() => {
         var result = InstantiatorCache.Get <PublicConstructors>(typeof(int)).New((double)2.2);
     });
 }
示例#4
0
 public void CreateNew_NoMatchingConstructor()
 {
     Assert.Throws <ApplicationException>(() => {
         var result = InstantiatorCache.Get <PublicConstructors>(typeof(double)).New((double)2.2);
     });
 }