public static DecompilationTestAttribute GetDecompilationTestAttribute(MethodInfo method)
        {
            object[] attributes = method.GetCustomAttributes(typeof(DecompilationTestAttribute), true);
            DecompilationTestAttribute attribute = null;

            if (attributes != null && attributes.Length > 0)
            {
                attribute = attributes[0] as DecompilationTestAttribute;
            }
            return(attribute);
        }
Пример #2
0
        public override void RunTestMethod(TestCaseResult testResult)
        {
            DecompilationTestAttribute attribute = DecompilationTestFactory.GetDecompilationTestAttribute(Method);
            var body = attribute.GetMethodBody(this.type);

            string path = string.Concat(DecompilationTestFixture.TestCasesDirectory, Path.DirectorySeparatorChar + resultFilename);

            if (attribute.Mode == Mode.MethodDefinition)
            {
                Reflect.InvokeMethod(Method, Fixture, new object[] { body.Method, File.ReadAllText(path) });
            }
            else
            {
                Reflect.InvokeMethod(Method, Fixture, new object[] { body, File.ReadAllText(path) });
            }
        }
        private static void PopulateTestSuite(MethodInfo method, DecompilationTestSuite suite)
        {
            DecompilationTestAttribute attribute = GetDecompilationTestAttribute(method);

            if (attribute == null)
            {
                throw new ArgumentException();
            }


            foreach (var value in Enum.GetValues(typeof(TestCaseType)))
            {
                var test = CreateTestCase(method, (TestCaseType)value, attribute.Filename, attribute.ResultFilename);
                if (test != null)
                {
                    suite.Add(test);
                }
            }
        }