Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider, IAssemblyInfo assemblyInfo, string assemblyFileName, string xunitExecutionAssemblyPath, string configFileName, bool shadowCopy, string shadowCopyFolder) { Guard.ArgumentNotNull("assemblyInfo", (object)assemblyInfo ?? assemblyFileName); #if PLATFORM_LINUX || PLATFORM_MACOS appDomain = new RemoteAppDomainManager(assemblyFileName ?? xunitExecutionAssemblyPath, configFileName, shadowCopy, shadowCopyFolder); assemblyInfo = new Xunit.Sdk.ReflectionAssemblyInfo(assemblyFileName); framework = new Xunit.Sdk.TestFrameworkProxy(assemblyInfo, sourceInformationProvider); discoverer = framework.GetDiscoverer(assemblyInfo); #else Guard.FileExists("xunitExecutionAssemblyPath", xunitExecutionAssemblyPath); appDomain = new RemoteAppDomainManager(assemblyFileName ?? xunitExecutionAssemblyPath, configFileName, shadowCopy, shadowCopyFolder); var testFrameworkAssemblyName = GetTestFrameworkAssemblyName(xunitExecutionAssemblyPath); // If we didn't get an assemblyInfo object, we can leverage the reflection-based IAssemblyInfo wrapper if (assemblyInfo == null) { assemblyInfo = appDomain.CreateObject <IAssemblyInfo>(testFrameworkAssemblyName, "Xunit.Sdk.ReflectionAssemblyInfo", assemblyFileName); } framework = appDomain.CreateObject <ITestFramework>(testFrameworkAssemblyName, "Xunit.Sdk.TestFrameworkProxy", assemblyInfo, sourceInformationProvider); discoverer = Framework.GetDiscoverer(assemblyInfo); #endif }
Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider, IAssemblyInfo assemblyInfo, string assemblyFileName, string xunitExecutionAssemblyPath, string configFileName, bool shadowCopy, string shadowCopyFolder, IMessageSink diagnosticMessageSink) { Guard.ArgumentNotNull("assemblyInfo", (object)assemblyInfo ?? assemblyFileName); Guard.FileExists("xunitExecutionAssemblyPath", xunitExecutionAssemblyPath); DiagnosticMessageSink = diagnosticMessageSink ?? new NullMessageSink(); appDomain = new RemoteAppDomainManager(assemblyFileName ?? xunitExecutionAssemblyPath, configFileName, shadowCopy, shadowCopyFolder); var testFrameworkAssemblyName = GetTestFrameworkAssemblyName(xunitExecutionAssemblyPath); // If we didn't get an assemblyInfo object, we can leverage the reflection-based IAssemblyInfo wrapper if (assemblyInfo == null) { assemblyInfo = appDomain.CreateObject <IAssemblyInfo>(testFrameworkAssemblyName, "Xunit.Sdk.ReflectionAssemblyInfo", assemblyFileName); } framework = appDomain.CreateObject <ITestFramework>(testFrameworkAssemblyName, "Xunit.Sdk.TestFrameworkProxy", assemblyInfo, sourceInformationProvider, DiagnosticMessageSink); discoverer = Framework.GetDiscoverer(assemblyInfo); }
Xunit2Discoverer(ISourceInformationProvider sourceInformationProvider, IAssemblyInfo assemblyInfo, string assemblyFileName, string xunitExecutionAssemblyPath, string configFileName, bool shadowCopy, string shadowCopyFolder) { Guard.ArgumentNotNull("assemblyInfo", (object)assemblyInfo ?? assemblyFileName); #if !ANDROID Guard.ArgumentValid("xunitExecutionAssemblyPath", "File not found: " + xunitExecutionAssemblyPath, File.Exists(xunitExecutionAssemblyPath)); #endif appDomain = new RemoteAppDomainManager(assemblyFileName ?? xunitExecutionAssemblyPath, configFileName, shadowCopy, shadowCopyFolder); #if !ANDROID var name = AssemblyName.GetAssemblyName(xunitExecutionAssemblyPath); var testFrameworkAssemblyName = name.FullName; #else var name = Assembly.Load(xunitExecutionAssemblyPath); var testFrameworkAssemblyName = name.FullName; #endif // If we didn't get an assemblyInfo object, we can leverage the reflection-based IAssemblyInfo wrapper if (assemblyInfo == null) { assemblyInfo = appDomain.CreateObject <IAssemblyInfo>(testFrameworkAssemblyName, "Xunit.Sdk.ReflectionAssemblyInfo", assemblyFileName); } framework = appDomain.CreateObject <ITestFramework>(testFrameworkAssemblyName, "Xunit.Sdk.TestFrameworkProxy", assemblyInfo, sourceInformationProvider); discoverer = Framework.GetDiscoverer(assemblyInfo); }
public DiaSessionWrapper(string assemblyFilename) { session = new DiaSession(assemblyFilename); var assemblyFileName = typeof(DiaSessionWrapperHelper).Assembly.GetLocalCodeBase(); appDomainManager = new RemoteAppDomainManager(assemblyFileName, null, true, null); helper = appDomainManager.CreateObject <DiaSessionWrapperHelper>(typeof(DiaSessionWrapperHelper).Assembly.FullName, typeof(DiaSessionWrapperHelper).FullName, assemblyFilename); }
/// <summary> /// Initializes a new instance of the <see cref="AppDomainTestFramework"/> class. /// </summary> /// <param name="sourceInformationProvider">The source code information provider.</param> /// <param name="assemblyFileName">The test assembly.</param> /// <param name="testFrameworkFileName">The file path of the test framework assembly (i.e., xunit2.dll).</param> /// <param name="testFrameworkTypeName">The fully qualified type name of the implementation of <see cref="ITestFramework"/> /// in the test framework assembly.</param> /// <param name="configFileName">The test assembly configuration file.</param> /// <param name="shadowCopy">If set to <c>true</c>, runs tests in a shadow copied app domain, which allows /// tests to be discovered and run without locking assembly files on disk.</param> public AppDomainTestFramework(ISourceInformationProvider sourceInformationProvider, string assemblyFileName, string testFrameworkFileName, string testFrameworkTypeName, string configFileName = null, bool shadowCopy = true) { Guard.ArgumentNotNull("sourceInformationProvider", sourceInformationProvider); Guard.ArgumentNotNullOrEmpty("testFrameworkFileName", testFrameworkFileName); testFrameworkFileName = Path.GetFullPath(testFrameworkFileName); Guard.ArgumentValid("testFrameworkFileName", "File not found: " + testFrameworkFileName, File.Exists(testFrameworkFileName)); SourceInformationProvider = sourceInformationProvider; // assemblyFileName might be null (during AST-based discovery), so pass along with the test // framework filename instead if we don't have an assembly under test yet. appDomain = new RemoteAppDomainManager(assemblyFileName ?? testFrameworkFileName, configFileName, shadowCopy); testFrameworkAssemblyName = AssemblyName.GetAssemblyName(testFrameworkFileName); testFramework = appDomain.CreateObject <ITestFramework>(testFrameworkAssemblyName.FullName, testFrameworkTypeName); testFramework.SourceInformationProvider = SourceInformationProvider; }
/// <summary> /// Creates an object (from the test framework assembly) in the remote app domain. /// </summary> /// <typeparam name="T">The type of the object to cast to.</typeparam> /// <param name="typeName">The fully qualified type name to create.</param> /// <param name="args">The arguments for the type's constructor.</param> /// <returns>An instance of the created object, cast to <typeparamref name="T"/>.</returns> public T CreateRemoteObject <T>(string typeName, params object[] args) { return(appDomain.CreateObject <T>(testFrameworkAssemblyName.FullName, typeName, args)); }
object CreateObject(string typeName, params object[] args) { return(appDomain.CreateObject <object>(xunitAssemblyName.FullName, typeName, args)); }