public void MixedPatternsAndDefaultOptions() { Type type = GetType(); SdkRegularExpressionMethodPointcut pcut = new SdkRegularExpressionMethodPointcut(); pcut.DefaultOptions = RegexOptions.None; pcut.Patterns = new object[] { "forMatching*", new Regex("xyz*", RegexOptions.Compiled) }; Assert.IsFalse(pcut.Matches(type.GetMethod("ForMatchingPurposesOnly"), type)); pcut.DefaultOptions = RegexOptions.IgnoreCase; pcut.Patterns = new object[] { "forMatching*", new Regex("xyz*", RegexOptions.Compiled) }; Assert.IsTrue(pcut.Matches(type.GetMethod("ForMatchingPurposesOnly"), type)); pcut.DefaultOptions = RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace; pcut.Patterns = new object[] { "for matc \nhing*", new Regex("xyz*", RegexOptions.Compiled) }; Assert.IsTrue(pcut.Matches(type.GetMethod("ForMatchingPurposesOnly"), type)); }
public void TryMatchesAfterSerialization() { SdkRegularExpressionMethodPointcut initial = new SdkRegularExpressionMethodPointcut(); initial.Pattern = "Foo"; SdkRegularExpressionMethodPointcut pcut = (SdkRegularExpressionMethodPointcut)SerializationTestUtils.SerializeAndDeserialize(initial); Assert.IsNotNull(pcut, "Deserialized instance must (obviously) not be null."); Type type = GetType(); bool isMatch = pcut.Matches(type.GetMethod("ForMatchingPurposesOnly"), type); Assert.IsFalse(isMatch, "Whoops, should not be matching here at all."); }