private void DoRunTest(Rule rule, List <TypeDefinition> types, AssemblyCache cache) { RuleDispatcher dispatcher = new RuleDispatcher(); rule.Register(dispatcher); m_failed = false; dispatcher.Dispatch(new BeginTesting()); dispatcher.Dispatch(Assembly); dispatcher.Dispatch(new BeginTypes()); foreach (TypeDefinition t in types) { dispatcher.Dispatch(t); } dispatcher.Dispatch(new EndTypes()); foreach (MethodInfo info in cache.Methods) { dispatcher.Dispatch(info); } dispatcher.DispatchCallGraph(); dispatcher.Dispatch(new EndTesting()); }
public void Test() { // Create the cache and the dispatcher. List <EventDefinition> events = new List <EventDefinition>(); events.AddRange(m_good); events.AddRange(m_bad); List <TypeDefinition> types = new List <TypeDefinition>(); types.AddRange(m_used); AssemblyCache cache = new AssemblyCache(Assembly, types); RuleDispatcher dispatcher = new RuleDispatcher(); // Create the rule. Rule rule = OnCreate(cache, this); // note that dispatcher will keep the rule from being GCed rule.Register(dispatcher); // Test the good events. foreach (EventDefinition evt in m_good) { m_failed = false; dispatcher.Dispatch(evt); if (m_failed) { Assert.Fail(string.Format("good {0} should have passed", evt.Name)); } } // Test the bad events. foreach (EventDefinition evt in m_bad) { m_failed = false; dispatcher.Dispatch(evt); if (!m_failed) { Assert.Fail(string.Format("bad {0} should have failed", evt.Name)); } } }
public void Test() { // Create the cache and the dispatcher. List <MethodInfo> methods = new List <MethodInfo>(); methods.AddRange(m_good); methods.AddRange(m_bad); methods.AddRange(m_used); TypeDefinition baseType = Assembly.MainModule.Types[GetType().FullName]; // some of the tests require an externally visible type AssemblyCache cache = new AssemblyCache(Assembly, baseType, methods); RuleDispatcher dispatcher = new RuleDispatcher(); // Create the rule. Rule rule = OnCreate(cache, this); // note that dispatcher will keep the rule from being GCed rule.Register(dispatcher); // Test the good methods. foreach (MethodInfo method in m_good) { m_failed = false; dispatcher.Dispatch(method.Method); dispatcher.Dispatch(method); if (m_failed) { Assert.Fail(string.Format("{0} should have passed", method.Method)); } } // Test the bad methods. foreach (MethodInfo method in m_bad) { m_failed = false; dispatcher.Dispatch(method.Method); dispatcher.Dispatch(method); if (!m_failed) { Assert.Fail(string.Format("{0} should have failed", method.Method)); } } }
private void DoVisit(RuleDispatcher dispatcher, TypeDefinition type) { dispatcher.Dispatch(type); // Some rules consider all the methods in a type. These rules cannot be tested // with a MethodTest so we'll visit methods here in order to be able to unit // test those rules. dispatcher.Dispatch(new BeginMethods(type)); foreach (MethodDefinition method in type.Constructors) { var minfo = new Smokey.Framework.Support.MethodInfo(type, method); dispatcher.Dispatch(minfo); } foreach (MethodDefinition method in type.Methods) { var minfo = new Smokey.Framework.Support.MethodInfo(type, method); dispatcher.Dispatch(minfo); } dispatcher.Dispatch(new EndMethods(type)); }
private void DoRunTest(Rule rule, List<TypeDefinition> types, AssemblyCache cache) { RuleDispatcher dispatcher = new RuleDispatcher(); rule.Register(dispatcher); m_failed = false; dispatcher.Dispatch(new BeginTesting()); dispatcher.Dispatch(Assembly); dispatcher.Dispatch(new BeginTypes()); foreach (TypeDefinition t in types) dispatcher.Dispatch(t); dispatcher.Dispatch(new EndTypes()); foreach (MethodInfo info in cache.Methods) { dispatcher.Dispatch(info); } dispatcher.DispatchCallGraph(); dispatcher.Dispatch(new EndTesting()); }
public void Test() { // Create the cache and the dispatcher. List<MethodInfo> methods = new List<MethodInfo>(); methods.AddRange(m_good); methods.AddRange(m_bad); methods.AddRange(m_used); TypeDefinition baseType = Assembly.MainModule.Types[GetType().FullName]; // some of the tests require an externally visible type AssemblyCache cache = new AssemblyCache(Assembly, baseType, methods); RuleDispatcher dispatcher = new RuleDispatcher(); // Create the rule. Rule rule = OnCreate(cache, this); // note that dispatcher will keep the rule from being GCed rule.Register(dispatcher); // Test the good methods. foreach (MethodInfo method in m_good) { m_failed = false; dispatcher.Dispatch(method.Method); dispatcher.Dispatch(method); if (m_failed) Assert.Fail(string.Format("{0} should have passed", method.Method)); } // Test the bad methods. foreach (MethodInfo method in m_bad) { m_failed = false; dispatcher.Dispatch(method.Method); dispatcher.Dispatch(method); if (!m_failed) Assert.Fail(string.Format("{0} should have failed", method.Method)); } }