public void Create_WithClassTypeAsParameter_ReturnsCorrectClass() { var classFactory = new ActivatorClassFactory(); var instance = classFactory.Create(typeof(ActivatorTestClass)); Assert.IsType <ActivatorTestClass>(instance); }
public void Create_GenericWithClassTypeAsGenericParameter_ReturnsCorrectClass() { var classFactory = new ActivatorClassFactory <ActivatorTestClass>(); var instance = classFactory.Create(); Assert.IsType <ActivatorTestClass>(instance); }
public void Create_GenericWithSetupWithClassTypeAsGenericParameter_ReturnsCorrectClass() { var classFactory = new ActivatorClassFactory <ActivatorTestClass>(); var instance = classFactory.Create(x => x.Text = "abcd"); Assert.IsType <ActivatorTestClass>(instance); Assert.Equal("abcd", instance.Text); }
public void Create_WithSetupWithClassTypeAsParameter_ReturnsCorrectClass() { var classFactory = new ActivatorClassFactory(); var instance = classFactory.Create(typeof(ActivatorTestClass), x => ((ActivatorTestClass)x).Text = "1234"); Assert.IsType <ActivatorTestClass>(instance); Assert.Equal("1234", ((ActivatorTestClass)instance).Text); }
public void Create_GenericWithSetupWithClassTypeAsGenericParameterForWrongType_ThrowsException() { var classFactory = new ActivatorClassFactory <ActivatorTestClassWithCtorParameters>(); Assert.Throws <MissingMethodException>(() => classFactory.Create(x => x.Text = "abcd")); }
public void Create_WithClassTypeAsParameterWithCtorParameters_ThrowsException() { var classFactory = new ActivatorClassFactory(); Assert.Throws <MissingMethodException>(() => classFactory.Create(typeof(ActivatorTestClassWithCtorParameters))); }