public Factory() { compiledTypeDefinition = TypeDefinition <IPerformanceTest> .Create(new DefaultProperty() .SkipIfEqual() .SetterGetter() .NotifyChanged()) .AddMethodMapper(main => new FormatClass(main)) .Compile(); }
public void ConstructorInitializedFieldInitialValueTest1() { CompiledTypeDefinition <ITestProperties> definition = TypeDefinition <ITestProperties> .Create() .Add(new PropertyDefinition <int>(nameof(ITestProperties.Property1)) .ConstructorParameter() .SetterGetter()) .Compile(); ITestProperties test = definition.Create(5); Assert.AreEqual(5, test.Property1); }
public void TestMethodProperty5() { TypeDefinition <ITestProperties> definition = TypeDefinition <ITestProperties> .Create() .Add(new PropertyDefinition <int>(nameof(ITestProperties.Property1)) .SetterGetter()); CompiledTypeDefinition <ITestProperties> compiledTypeDefinition = definition.Compile(); ITestProperties test1 = compiledTypeDefinition.Create(); ITestProperties test2 = compiledTypeDefinition.Create(); test1.Property1 = 42; Assert.AreEqual(0, test2.Property1); }
public void ConstructorInitializedFieldEventWithReturnValue1() { CompiledTypeDefinition <ITestEvents> compiledTypeDefinition = TypeDefinition <ITestEvents> .Create().Compile(); ITestEvents test = compiledTypeDefinition.Create(); Action <string> trigger = new EventTrigger(test, nameof(ITestEvents.WithReturnValue)).ToAction <string>(); bool withReturnValueEventCalled = false; bool otherEventCalled = false; test.Simple += delegate { otherEventCalled = true; }; test.WithParameters += delegate { otherEventCalled = true; }; test.WithReturnValue += delegate { return(withReturnValueEventCalled = true); }; trigger(""); Assert.IsTrue(withReturnValueEventCalled); Assert.IsFalse(otherEventCalled); }