コード例 #1
0
 /// <summary>
 /// Adds the standard methods.
 /// </summary>
 /// <param name="assembly">The assembly.</param>
 private static void addStandardMethods(TestingAssembly assembly)
 {
     assembly.AddMethod("Test.Report", (c) =>
     {
         AssemblyUtils.REPORTED_INSTANCE = c.CurrentArguments[1];
     }, Method.Void_ObjectParam);
 }
コード例 #2
0
        /// <summary>
        /// Test that entry source is equivalent to given source after edit actions.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <param name="source">Expected source.</param>
        public static void AssertSourceEquivalence(this TestingAssembly assembly, string source)
        {
            var result       = assembly.GetResult(Method.EntryInfo.MethodID);
            var editedSource = assembly.GetEntrySource(result.View);

            var nSource       = normalizeCode("{" + source + "}");
            var nEditedSource = normalizeCode(editedSource);

            Assert.AreEqual(nSource, nEditedSource);
        }
コード例 #3
0
        /// <summary>
        /// Gets the test result from test defined in assembly.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <param name="entryMethod">The entry method of test.</param>
        /// <returns>TestResult.</returns>
        public static TestResult GetResult(this TestingAssembly assembly, MethodID entryMethod)
        {
            if (!assembly.IsBuilded)
            {
                assembly.Build();
            }

            var entryObj = assembly.Machine.CreateInstance(TypeDescriptor.Create(Method.EntryClass));

            return(GetResult(assembly, entryMethod, entryObj));
        }
コード例 #4
0
        /// <summary>
        /// Gets the test result from test defined in assembly.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <param name="entryMethod">The entry method of test.</param>
        /// <param name="entryArguments">The entry method arguments.</param>
        /// <returns>TestResult.</returns>
        public static TestResult GetResult(this TestingAssembly assembly, MethodID entryMethod, params Instance[] entryArguments)
        {
            if (!assembly.IsBuilded)
            {
                assembly.Build();
            }

            var result = assembly.Machine.Run(assembly.Loader, entryMethod, entryArguments);

            foreach (var action in assembly.UserActions)
            {
                action(result);
            }

            var view = processEdits(assembly.Runtime, result, assembly.EditActions);

            return(new TestResult(view, result));
        }
コード例 #5
0
 /// <summary>
 /// Asserts return value of entry method.
 /// </summary>
 /// <param name="assembly">The assembly.</param>
 /// <returns>TestCase.</returns>
 internal static TestCase AssertReturn(this TestingAssembly assembly)
 {
     return(AssertVariable(assembly, null));
 }
コード例 #6
0
        /// <summary>
        /// Asserts condition on the variable. E.g. HasValue condition can be used.
        /// </summary>
        /// <param name="assembly">The assembly.</param>
        /// <param name="variableName">Name of the variable.</param>
        /// <returns>TestCase.</returns>
        internal static TestCase AssertVariable(this TestingAssembly assembly, string variableName)
        {
            var result = assembly.GetResult(Method.EntryInfo.MethodID);

            return(new TestCase(result, variableName));
        }
コード例 #7
0
 /// <summary>
 /// Gets the entry source.
 /// </summary>
 /// <param name="assembly">The assembly.</param>
 /// <param name="view">The view.</param>
 /// <returns>System.String.</returns>
 public static string GetEntrySource(this TestingAssembly assembly, ExecutionView view)
 {
     return(assembly.GetSource(Method.EntryInfo.MethodID, view));
 }