/// <summary> /// If the property is PropertyChanged it does nothing. /// For any other property this method will throw a NotSupportedException(). /// </summary> protected override void ImplementEvent <T>(FluentTypeBuilder <TAbstract> typeBuilder, EventInfo eventInfo) { if (eventInfo.EventHandlerType != typeof(PropertyChangedEventHandler) || eventInfo.Name != "PropertyChanged") { throw new NotSupportedException(); } }
public void GivenEmittedClassITestMethodsImplementsCanCallMethodThatReturnsAString() { //Assign var typeBuilder = new FluentTypeBuilder(AppDomain.CurrentDomain) .SetAssemblyName("Test") .Implements <ITestMethods>() .ImplementInterface(); typeBuilder.SetTypeName("Test").CreateType().Save(); //Act var testMethods = typeBuilder.CreateInstance(); //Act testMethods.GetType().GetMethod("SomeOtherMethod").ReturnType.Should().Be <string>(); }
public void BuiltTypeImplementsITest() { //Assign var typeBuilder = new FluentTypeBuilder(AppDomain.CurrentDomain) .SetAssemblyName("Test") .Implements <ITest>(); typeBuilder.SetTypeName("Test").CreateType(); var assembly = typeBuilder.ModuleBuilder.Assembly; //Act var definedTypes = assembly.DefinedTypes.Single(x => x.FullName == "Test"); //Assert definedTypes.ImplementedInterfaces.Should().Contain(typeof(ITest)); }
/// <summary> /// Throws a NotSupportedException as this type only implements properties. /// </summary> protected override void ImplementIndexerUntyped(FluentTypeBuilder <TAbstract> typeBuilder, PropertyInfo indexer) { throw new NotImplementedException(); }
/// <summary> /// Throws a NotSupportedException as this type only implements properties. /// </summary> protected override void ImplementMethod(FluentTypeBuilder <TAbstract> typeBuilder, MethodInfo method) { throw new NotSupportedException(); }
/// <summary> /// Asks the NotifyPropertyChangedGenerator to implement the property /// using its own backing field. /// </summary> protected override void ImplementProperty <T>(FluentTypeBuilder <TAbstract> typeBuilder, PropertyInfo property) { _generator.AddProperty <T>(property.Name); }
public void SetUp() { this.Sut = new FluentTypeBuilder(Thread.GetDomain()); }