Exemplo n.º 1
0
 /// <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();
     }
 }
Exemplo n.º 2
0
        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>();
        }
Exemplo n.º 3
0
        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));
        }
Exemplo n.º 4
0
 /// <summary>
 /// Throws a NotSupportedException as this type only implements properties.
 /// </summary>
 protected override void ImplementIndexerUntyped(FluentTypeBuilder <TAbstract> typeBuilder, PropertyInfo indexer)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
 /// <summary>
 /// Throws a NotSupportedException as this type only implements properties.
 /// </summary>
 protected override void ImplementMethod(FluentTypeBuilder <TAbstract> typeBuilder, MethodInfo method)
 {
     throw new NotSupportedException();
 }
Exemplo n.º 6
0
 /// <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());
 }