public void Create_WithClassTypeAsParameter_ReturnsCorrectClass() { var classFactory = new DelegateClassFactory(CreateClass); var instance = classFactory.Create(typeof(DelegateTestClass)); Assert.IsType <DelegateTestClass>(instance); }
public void Create_GenericWithClassTypeAsGenericParameter_ReturnsCorrectClass() { var classFactory = new DelegateClassFactory <DelegateTestClass>(() => new DelegateTestClass()); var instance = classFactory.Create(); Assert.IsType <DelegateTestClass>(instance); }
public void Create_GenericWithSetupWithClassTypeAsGenericParameter_ReturnsCorrectClass() { var classFactory = new DelegateClassFactory <DelegateTestClass>(() => new DelegateTestClass()); var instance = classFactory.Create(x => x.Text = "abcd"); Assert.IsType <DelegateTestClass>(instance); Assert.Equal("abcd", instance.Text); }
public void Create_WithSetupWithClassTypeAsParameter_ReturnsCorrectClass() { var classFactory = new DelegateClassFactory(CreateClass); var instance = classFactory.Create(typeof(DelegateTestClass), x => ((DelegateTestClass)x).Text = "1234"); Assert.IsType <DelegateTestClass>(instance); Assert.Equal("1234", ((DelegateTestClass)instance).Text); }
public void Create_GenericWithSetupWithClassTypeAsGenericParameterForWrongType_ThrowsException() { var classFactory = new DelegateClassFactory <DelegateTestClass>(CreateClass <DelegateTestClass>); Assert.Throws <InvalidOperationException>(() => classFactory.Create(x => x.Text = "abcd")); }
public void Create_GenericWithWrongClassTypeAsParameter_ThrowsException() { var classFactory = new DelegateClassFactory <DelegateTestClass>(() => new DelegateTestClass()); Assert.Throws <InvalidOperationException>(() => classFactory.Create(typeof(string))); }