public static void AssertEq(object expected, string exportedFunctionName, params object[] values) { var assembly = Assembly.GetCallingAssembly(); var exports = ExportTable.GetExports(assembly); var export = exports[exportedFunctionName]; var result = export.Invoke(null, values); var expectedText = Convert.ToString(expected); var actualText = Convert.ToString(result); var passed = (expectedText == actualText); if (!passed) { Environment.ExitCode = 1; } if (QuietMode && passed) { return; } PrintHeader(assembly); Console.WriteLine( "(invoke \"{1}\" {2}){0}" + "-> {3} '{4}' == '{5}'", Environment.NewLine, exportedFunctionName, string.Join(" ", values), passed ? "pass" : "fail", expectedText, actualText ); }
public static void Invoke(string exportedFunctionName, params object[] values) { var assembly = Assembly.GetCallingAssembly(); var exports = ExportTable.GetExports(assembly); var export = exports[exportedFunctionName]; object result; try { result = export.Invoke(null, values); } catch (Exception exc) { throw new Exception(string.Format("Invoke('{0}', ...) failed ", exportedFunctionName), exc); } if (QuietMode && (export.ReturnType.FullName == "System.Void")) { return; } PrintHeader(assembly); if (export.ReturnType.Name != "Void") { Console.WriteLine( "(invoke \"{1}\" {2}){0}" + "-> {3}", Environment.NewLine, exportedFunctionName, string.Join(" ", values), result ); } else { Console.WriteLine( "(invoke \"{0}\" {1})", exportedFunctionName, string.Join(" ", values) ); } }
public static void Invoke(string exportedFunctionName, params object[] values) { var assembly = Assembly.GetCallingAssembly(); var exports = ExportTable.GetExports(assembly); var export = exports[exportedFunctionName]; var result = export.Invoke(null, values); if (QuietMode && (export.ReturnType.FullName == "System.Void")) { return; } PrintHeader(assembly); Console.WriteLine( "(invoke \"{1}\" {2}){0}" + "-> {3}", Environment.NewLine, exportedFunctionName, string.Join(" ", values), result ); }