public void ThrowsAnExceptionWhenTheTypeDoesNotHaveAPublicParameterlessConstructorOrAConstructorWhoseParametersAllHaveADefaultValue() { var assemblyQualifiedName = typeof(Baz).AssemblyQualifiedName; Assert.That( () => SlowFactory.CreateInstance <IBaz>(assemblyQualifiedName), Throws.Exception.Message.ContainsSubstring("Unable to find suitable constructor for")); }
public void ThrowsAnExceptionWhenTheTypeIsNotAssignableToTheGenericTypeArgument() { var assemblyQualifiedName = typeof(Foo).AssemblyQualifiedName; Assert.That( () => SlowFactory.CreateInstance <IBar>(assemblyQualifiedName), Throws.Exception.Message.ContainsSubstring("type is not assignable to the")); }
public void ThrowsAnExceptionWhenTheTypeIsAbstract() { var assemblyQualifiedName = typeof(IFoo).AssemblyQualifiedName; Assert.That( () => SlowFactory.CreateInstance <IFoo>(assemblyQualifiedName), Throws.Exception.Message.ContainsSubstring("Unable to create instance of abstract type")); }
public void ThrowsAnExceptionWhenTheAssemblyQualifiedNameCanNotBeLocated() { const string assemblyQualifiedName = "this string is not the assembly qualified name of any type"; Assert.That( () => SlowFactory.CreateInstance <IFoo>(assemblyQualifiedName), Throws.Exception.Message.ContainsSubstring("Unable to locate a type with the name of")); }
public void ReturnsAnInstanceOfATypeThatHasAPublicParameterlessConstructor() { var assemblyQualifiedName = typeof(Foo).AssemblyQualifiedName; Assert.That(SlowFactory.CreateInstance <IFoo>(assemblyQualifiedName), Is.InstanceOf <Foo>()); }
public void ReturnsAnInstanceOfATypeThatHasAPublicConstructorWhoseParametersAllHaveADefaultValue() { var assemblyQualifiedName = typeof(Bar).AssemblyQualifiedName; Assert.That(SlowFactory.CreateInstance <IBar>(assemblyQualifiedName), Is.InstanceOf <Bar>()); }