public void CreateInstance_returns_exception_for_failing_method( ) { IInstanceCreator creator = InstanceCreator.ForType <FailingClass>( ); object result = creator.CreateInstance( ); var actual = Assert.IsType <Exception>(result); Assert.Equal(typeof(FailingClass).FullName, actual.Message); }
public void CreateInstance_succeeds_for_parameterized_class_constructor( ) { var type = typeof(InstantiableClass); var constructor = type.GetConstructor(new[] { type }); Assert.NotNull(constructor); var parameter = InstanceCreator.ForType <InstantiableClass>( ); var creator = InstanceCreator.ForMethod <InstantiableClass>(constructor, parameter); TestCreator(creator); }
public void CreateInstance_succeeds_for_parameterized_method( ) { var type = typeof(InstantiableClass); var method = type.GetMethod("ParameterizedMethod"); Assert.NotNull(method); var parameter = InstanceCreator.ForType <InstantiableClass>( ); var creator = InstanceCreator.ForMethod <InstantiableClass>(method, parameter); TestCreator(creator); }
public void CreateInstance_succeeds_for_derived_class_constructor( ) { var type = typeof(DerivedInstantiableClass); var constructor = type.GetConstructor(new[] { type }); Assert.NotNull(constructor); var parameter = InstanceCreator.ForType <InstantiableClass>( ); var creator = InstanceCreator.ForMethod <InstantiableClass>(constructor, parameter); var result = TestCreator(creator); Assert.True(type.IsInstanceOfType(result)); }
public void CreateInstance_succeeds_for_default_class_constructor( ) { var creator = InstanceCreator.ForType <InstantiableClass>( ); TestCreator(creator); }