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