public static InterfaceAssembly.ITestReference CreateITestReferenceInstance(string assemblyPath, string className) { InterfaceAssembly.ITestReference testReferenceImpl = null; string assemblyLocation = System.IO.Path.GetFullPath(assemblyPath); try { Assembly assembly = AssemblyLoadContext.Default.LoadFromAssemblyPath( Regex.Replace(assemblyLocation, "^file:(/+)?", "")); Type type = assembly.GetType(className); var testRefereceCreated = Activator.CreateInstance(type); testReferenceImpl = testRefereceCreated as InterfaceAssembly.ITestReference; } catch (Exception e) { var msg = string.Format( "Unable to load assembly or type. A: {0}, T: {1}. Error: {2}" , assemblyLocation , className, e.Message); throw new Exception(msg, e); } return(testReferenceImpl); }
private static void ExecuteTestReference(InterfaceAssembly.ITestReference testReference) { try { InterfaceAssembly.TestRequest request = new InterfaceAssembly.TestRequest() { Information = string.Format("I am about to send in the request from class: [{0}]", typeof(Program).FullName) }; System.Console.WriteLine(testReference.DoSomething(request).Information); } catch (Exception ex) { System.Console.WriteLine(ex.Message); } }