/// <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); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }