示例#1
0
        /// <summary>
        /// Runs the specified entry method source in raw C# (no block parentheses are added).
        /// </summary>
        /// <param name="rawEntryMethodSource">The raw entry method source.</param>
        /// <returns>TestingAssembly.</returns>
        public static TestingAssembly RunRaw(string rawEntryMethodSource)
        {
            var assembly = SettingsProvider.CreateTestingAssembly();

            assembly.AddMethodRaw(Method.EntryMethodPath, rawEntryMethodSource, Method.Entry_NoParam);

            addStandardMethods(assembly);

            return(assembly);
        }
示例#2
0
        /// <summary>
        /// Runs the given CIL method.
        /// </summary>
        /// <param name="sourceMethod">The source method.</param>
        /// <returns>TestingAssembly.</returns>
        public static TestingAssembly RunCIL(Action sourceMethod)
        {
            var assembly = SettingsProvider.CreateTestingAssembly();

            assembly.AddMethod(Method.EntryMethodPath, sourceMethod.Method, Method.Entry_NoParam);

            addStandardMethods(assembly);

            return(assembly);
        }
示例#3
0
        /// <summary>
        /// Runs method generated by the specified director.
        /// </summary>
        /// <param name="director">The director that emits method's instructions.</param>
        /// <returns>Result of test analysis that can be tested by assertions.</returns>
        internal static TestResult Run(EmitDirector director)
        {
            var assembly = SettingsProvider.CreateTestingAssembly();

            var machine = SettingsProvider.CreateMachine(assembly.Settings);

            assembly.Runtime.BuildAssembly();
            var loader = new EmitDirectorLoader(director, assembly.Loader);

            return(new TestResult(machine.Run(loader, loader.EntryPoint)));
        }
示例#4
0
        /// <summary>
        /// Runs the given CIL method.
        /// </summary>
        /// <param name="sourceMethod">The CIL method.</param>
        /// <returns>TestingAssembly.</returns>
        public static TestingAssembly RunCIL(Func <object> sourceMethod)
        {
            var assembly = SettingsProvider.CreateTestingAssembly();

            var description = MethodDescription.Create <object>(false);

            assembly.AddMethod(Method.EntryMethodPath, sourceMethod.Method, description);

            addStandardMethods(assembly);

            return(assembly);
        }
示例#5
0
        /// <summary>
        /// Runs the method from given assembly at given method path.
        /// CECIL transcription to IAL is used.
        /// </summary>
        /// <param name="assemblyPath">The assembly path.</param>
        /// <param name="methodPath">The method path.</param>
        /// <returns>TestingAssembly.</returns>
        public static TestingAssembly RunCECIL(string assemblyPath, string methodPath)
        {
            var sourceMethod = FindMethod(assemblyPath, methodPath);
            var assembly     = SettingsProvider.CreateTestingAssembly();

            var description = new MethodDescription(TypeDescriptor.Create(sourceMethod.ReturnType.FullName), false);

            assembly.AddMethod(Method.EntryMethodPath, sourceMethod, description);

            addStandardMethods(assembly);

            return(assembly);
        }