public void WithOnChangedAbstract() { var instance = assembly.GetInstance("ClassWithOnChangedConcrete"); Assert.IsFalse(instance.OnProperty1ChangedCalled); EventTester.TestProperty(instance, false); Assert.IsTrue(instance.OnProperty1ChangedCalled); }
public void WithDoNotSetChanged() { var instance = assembly.GetInstance("ClassWithDoNotSetChanged"); Assert.IsFalse(instance.IsChanged); EventTester.TestProperty(instance, false); Assert.IsFalse(instance.IsChanged); }
public void Nested() { var instance1 = assembly.GetInstance("ClassWithNested+ClassNested"); EventTester.TestProperty(instance1, false); var instance2 = assembly.GetInstance("ClassWithNested+ClassNested+ClassNestedNested"); EventTester.TestProperty(instance2, false); }
public void CaliburnOverriddenInvoker() { var instance = assembly.GetInstance("ClassCaliburnOverriddenInvoker"); EventTester.TestProperty(instance, false); Assert.IsTrue(instance.BaseNotifyCalled); Assert.IsTrue(instance.OverrideCalled); }
public virtual void Nested() { var instance1 = testResult.GetInstance("ClassWithNested+ClassNested"); EventTester.TestProperty(instance1, false); var instance2 = testResult.GetInstance("ClassWithNested+ClassNested+ClassNestedNested"); EventTester.TestProperty(instance2, false); }
public void TestClassIsNotBlocked() { var weavingTask = new ModuleWeaver(); var testResult = weavingTask.ExecuteTestRun( "AssemblyWithBlockingClass.dll", ignoreCodes: new[] { "0x80131869" }); var instance = testResult.GetInstance("B"); EventTester.TestProperty(instance, false); }
public void StaticEquals_Hierarchy() { Weave(true); var instance = testResult.GetInstance("AssemblyWithBaseInDifferentModule.Hierarchy.ChildClass"); EventTester.TestProperty(instance, true); Assert.NotNull(instance.Property2); Assert.True(instance.Property2.StaticEqualsCalled); instance.Property2.StaticEqualsCalled = false; }
public void GenericBase_MultipleBaseClasses_GenericArgsMapping_BaseHasMoreArgs() { Weave(true); var instance = testResult.GetInstance("AssemblyWithBaseInDifferentModule.StaticEqualsGenericParent.ArgsMapping2"); EventTester.TestProperty(instance, true); Assert.NotNull(instance.Property2); Assert.True(instance.Property2.StaticEqualsCalled); instance.Property2.StaticEqualsCalled = false; }
public void GenericBase_StaticEquals_BaseNotUsed() { Weave(false); var instance = testResult.GetInstance("AssemblyWithBaseInDifferentModule.StaticEqualsGenericParent.StaticEqualsOnBase"); EventTester.TestProperty(instance, true); Assert.NotNull(instance.Property2); Assert.False(instance.Property2.StaticEqualsCalled); instance.Property2.StaticEqualsCalled = false; }
public void GenericBase_OwnStaticEquals() { Weave(true); var instance = testResult.GetInstance("AssemblyWithBaseInDifferentModule.StaticEqualsGenericParent.OwnStaticEquals"); EventTester.TestProperty(instance, true); Assert.NotNull(instance.Property2); Assert.True(instance.Property2.ChildStaticEqualsCalled); Assert.False(instance.Property2.StaticEqualsCalled); instance.Property2.ChildStaticEqualsCalled = false; }
public void DoNotCheckEquality() { var instance = assembly.GetInstance("ClassDoNotCheckEquality"); EventTester.TestProperty(instance, "Property1", "aString"); instance.Property1 = "aString"; Assert.AreEqual(1, instance.TimesProperty1Changed); EventTester.TestProperty(instance, "Property2", "aString", true); instance.Property2 = "aString"; Assert.AreEqual(2, instance.TimesProperty2Changed); }
public void CheckIfFilterTypeExcludeRightTypes() { var weaverHelper = new WeaverHelper(@"AssemblyWithTypeFilter\AssemblyWithTypeFilter.csproj"); var assembly = weaverHelper.Assembly; var instance = assembly.GetInstance("TestClassExclude"); EventTester.TestPropertyNotCalled(instance); instance = assembly.GetInstance("PropertyChangedTest.TestClassInclude"); EventTester.TestProperty(instance, false); Verifier.Verify(weaverHelper.BeforeAssemblyPath, weaverHelper.AfterAssemblyPath); }
public void Equality() { var instance = assembly.GetInstance("ClassEquality"); EventTester.TestProperty(instance, "StringProperty", "foo"); EventTester.TestProperty(instance, "IntProperty", 2); EventTester.TestProperty(instance, "NullableIntProperty", 2); EventTester.TestProperty(instance, "BoolProperty", true); EventTester.TestProperty(instance, "NullableBoolProperty", true); EventTester.TestProperty(instance, "ObjectProperty", "foo"); EventTester.TestProperty(instance, "ArrayProperty", new[] { "foo" }); }
public void DoNotCheckEqualityAppliesToWholeClassInherited() { var propertyValue = "aString"; dynamic instance = assembly.GetInstance("ClassDoNotCheckEqualityWholeClassInherited"); EventTester.TestProperty(instance, "Property1", propertyValue, true); instance.Property1 = propertyValue; Assert.AreEqual(2, instance.TimesProperty1Changed); EventTester.TestProperty(instance, "Property2", propertyValue, true); instance.Property2 = propertyValue; Assert.AreEqual(2, instance.TimesProperty2Changed); }
public void BeforeAfter() { var weaverHelper = new WeaverHelper(@"AssemblyWithBeforeAfterInterceptor\AssemblyWithBeforeAfterInterceptor.csproj", true); var assembly = weaverHelper.Assembly; var instance = assembly.GetInstance("ClassToTest"); EventTester.TestProperty(instance, false); var type = assembly.GetType("PropertyNotificationInterceptor"); var propertyInfo = type.GetProperty("InterceptCalled", BindingFlags.Static | BindingFlags.Public); var value = (bool)propertyInfo.GetValue(null, null); Assert.IsTrue(value); Verifier.Verify(assembly.CodeBase.Replace("file:///", string.Empty)); }
public void BeforeAfter() { var weavingTask = new ModuleWeaver(); var testResult = weavingTask.ExecuteTestRun("AssemblyWithBeforeAfterInterceptor.dll"); var assembly = testResult.Assembly; var instance = assembly.GetInstance("ClassToTest"); EventTester.TestProperty(instance, false); var type = assembly.GetType("PropertyChangedNotificationInterceptor"); var propertyInfo = type.GetProperty("InterceptCalled", BindingFlags.Static | BindingFlags.Public); var value = (bool)propertyInfo.GetValue(null, null); Assert.True(value); }
public void BeforeAfter() { var weaverHelper = new WeaverHelper("AssemblyWithBeforeAfterInterceptor"); var assembly = weaverHelper.Assembly; var instance = assembly.GetInstance("ClassToTest"); EventTester.TestProperty(instance, false); var type = assembly.GetType("PropertyChangedNotificationInterceptor"); var propertyInfo = type.GetProperty("InterceptCalled", BindingFlags.Static | BindingFlags.Public); var value = (bool)propertyInfo.GetValue(null, null); Assert.IsTrue(value); Verifier.Verify(weaverHelper.BeforeAssemblyPath, weaverHelper.AfterAssemblyPath); }
public void Equality() { var instance = assembly.GetInstance("ClassEquality"); EventTester.TestProperty(instance, "StringProperty", "foo"); EventTester.TestProperty(instance, "IntProperty", 2); EventTester.TestProperty(instance, "NullableIntProperty", 2); EventTester.TestProperty(instance, "BoolProperty", true); EventTester.TestProperty(instance, "NullableBoolProperty", true); EventTester.TestProperty(instance, "ObjectProperty", "foo"); EventTester.TestProperty(instance, "ShortProperty", (short)1); EventTester.TestProperty(instance, "UShortProperty", (ushort)1); EventTester.TestProperty(instance, "ByteProperty", (byte)1); EventTester.TestProperty(instance, "SByteProperty", (sbyte)1); EventTester.TestProperty(instance, "CharProperty", 'd'); }
public virtual void Equality() { var instance = testResult.GetInstance("ClassEquality"); EventTester.TestProperty(instance, "StringProperty", "foo"); EventTester.TestProperty(instance, "IntProperty", 2); EventTester.TestProperty(instance, "NullableIntProperty", 2); EventTester.TestProperty(instance, "BoolProperty", true); EventTester.TestProperty(instance, "NullableBoolProperty", true); EventTester.TestProperty(instance, "ObjectProperty", "foo"); EventTester.TestProperty(instance, "ArrayProperty", new[] { "foo" }); EventTester.TestProperty(instance, "ShortProperty", (short)1); EventTester.TestProperty(instance, "UShortProperty", (ushort)1); EventTester.TestProperty(instance, "ByteProperty", (byte)1); EventTester.TestProperty(instance, "SByteProperty", (sbyte)1); EventTester.TestProperty(instance, "CharProperty", 'd'); }
public void ClassWithGenericTypeInInheritanceChainUsesCorrectEventInvoker() { // Issue #477 Weave(false); using (var module = ModuleDefinition.ReadModule(testResult.AssemblyPath)) { var typeDef = module.GetType(nameof(ClassWithGenericMiddleChildInDifferentModule)); var setter = typeDef.Methods.Single(m => m.Name == "set_" + nameof(ClassWithGenericMiddleChildInDifferentModule.Property)); var callInstruction = setter.Body.Instructions.Single(i => i.OpCode == OpCodes.Callvirt); Assert.Equal(nameof(BaseClassWithGenericMiddleBase), ((MethodReference)callInstruction.Operand).DeclaringType.FullName); } var instance = testResult.GetInstance(nameof(ClassWithGenericMiddleChildInDifferentModule)); EventTester.TestProperty(instance, nameof(ClassWithGenericMiddleChildInDifferentModule.Property), 42); }
public void WithNotifyInBase() { var instance = assembly.GetInstance("ClassWithNotifyInBase"); EventTester.TestProperty(instance, true); }
public void WithPropertyImpOfAbstractProperty() { var instance = assembly.GetInstance("ClassWithPropertyImp"); EventTester.TestProperty(instance, false); }
public void GenericBaseWithPropertyOnChanged() { var instance = assembly.GetInstance("GenericBaseWithPropertyOnChanged.ClassWithGenericPropertyChild"); EventTester.TestProperty(instance, false); }
public void WithGenericAmdLambda() { var instance = assembly.GetInstance("ClassWithGenericAmdLambdaImp"); EventTester.TestProperty(instance, false); }
public void WithCustomEventInvoker() { var instance = assembly.GetInstance("ClassWithCustomEventInvoker"); EventTester.TestProperty(instance, false); }
public void ClassWithFieldGetButNoFieldSet() { var instance = assembly.GetInstance("ClassWithFieldGetButNoFieldSet"); EventTester.TestProperty(instance, false); }
public void WithLogicInSet() { var instance = assembly.GetInstance("ClassWithLogicInSet"); EventTester.TestProperty(instance, false); }
public void WithFields() { var instance = assembly.GetInstance("ClassWithFields"); EventTester.TestProperty(instance, true); }
public void DependsOn() { var instance = assembly.GetInstance("ClassDependsOn"); EventTester.TestProperty(instance, true); }
public void Child2() { var instance = assembly.GetInstance("ComplexHierachy.ClassChild2"); EventTester.TestProperty(instance, false); }