public StatLightConfiguration GetStatLightConfigurationForDll(UnitTestProviderType unitTestProviderType, string dllPath, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion, Collection<string> methodsToTest, string tagFilters, int numberOfBrowserHosts, bool isRemoteRun, string queryString, WebBrowserType webBrowserType, bool forceBrowserStart, bool showTestingBrowserHost) { if (queryString == null) throw new ArgumentNullException("queryString"); Func<IEnumerable<ITestFile>> filesToCopyIntoHostXap = () => new List<ITestFile>(); string entryPointAssembly = string.Empty; string runtimeVersion = null; if (isRemoteRun) { } else { AssertFileExists(dllPath); var dllFileInfo = new FileInfo(dllPath); var assemblyResolver = new AssemblyResolver(_logger); var dependentAssemblies = assemblyResolver.ResolveAllDependentAssemblies(dllFileInfo.FullName); var coreFileUnderTest = new TestFile(dllFileInfo.FullName); var dependentFilesUnderTest = dependentAssemblies.Select(file => new TestFile(file)).ToList(); dependentFilesUnderTest.Add(coreFileUnderTest); var xapReadItems = new TestFileCollection(_logger, AssemblyName.GetAssemblyName(dllFileInfo.FullName).ToString(), dependentFilesUnderTest); SetupUnitTestProviderType(xapReadItems, ref unitTestProviderType, ref microsoftTestingFrameworkVersion); entryPointAssembly = xapReadItems.TestAssemblyFullName; filesToCopyIntoHostXap =()=> { return new TestFileCollection(_logger, AssemblyName.GetAssemblyName(dllFileInfo.FullName) .ToString(), dependentFilesUnderTest).FilesContainedWithinXap; }; } var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, methodsToTest, tagFilters, numberOfBrowserHosts, webBrowserType, showTestingBrowserHost, entryPointAssembly); var serverConfig = CreateServerConfiguration( dllPath, clientConfig.UnitTestProviderType, microsoftTestingFrameworkVersion, filesToCopyIntoHostXap, DefaultDialogSmackDownElapseMilliseconds, queryString, forceBrowserStart, showTestingBrowserHost, runtimeVersion); return new StatLightConfiguration(clientConfig, serverConfig); }
public XapHostType MapToXapHostType(UnitTestProviderType unitTestProviderType, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion) { Action throwNotSupportedException = () => { throw new NotSupportedException( "Cannot map to a xap host based on the following input values UnitTestProviderType={0}, MicrosoftTestingFrameworkVersion={1}" .FormatWith(unitTestProviderType, microsoftTestingFrameworkVersion)); }; switch (unitTestProviderType) { case UnitTestProviderType.NUnit: case UnitTestProviderType.XUnitLight: return XapHostType.MSTestMay2010; case UnitTestProviderType.MSTestWithCustomProvider: case UnitTestProviderType.MSTest: if(microsoftTestingFrameworkVersion.HasValue) { var msTestVersionXapHostStringName = "MSTest" + microsoftTestingFrameworkVersion.Value; if (Enum.IsDefined(typeof(XapHostType), msTestVersionXapHostStringName)) return (XapHostType)Enum.Parse(typeof(XapHostType), msTestVersionXapHostStringName); } throwNotSupportedException(); break; case UnitTestProviderType.UnitDriven: return XapHostType.UnitDrivenDecember2009; case UnitTestProviderType.Xunit: return XapHostType.XunitContribApril2011; case UnitTestProviderType.Undefined: default: throwNotSupportedException(); break; } return XapHostType.UnitDrivenDecember2009; }
private ServerTestRunConfiguration CreateServerConfiguration( string xapPath, UnitTestProviderType unitTestProviderType, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion, Func<IEnumerable<ITestFile>> filesToCopyIntoHostXapFunc, string queryString, bool forceBrowserStart, WindowGeometry windowGeometry, string runtimeVersion) { XapHostType xapHostType = _xapHostFileLoaderFactory.MapToXapHostType(unitTestProviderType, microsoftTestingFrameworkVersion); Func<byte[]> hostXapFactory = () => { byte[] hostXap = _xapHostFileLoaderFactory.LoadXapHostFor(xapHostType); hostXap = RewriteXapWithSpecialFiles(hostXap, filesToCopyIntoHostXapFunc, runtimeVersion); return hostXap; }; return new ServerTestRunConfiguration(hostXapFactory, xapPath, xapHostType, queryString, forceBrowserStart, windowGeometry); }
private static void SetupUnitTestProviderType(TestFileCollection testFileCollection, ref UnitTestProviderType unitTestProviderType, ref MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion) { if (unitTestProviderType == UnitTestProviderType.Undefined || microsoftTestingFrameworkVersion == null) { //TODO: Print message telling the user what the type is - and if they give it // we don't have to "reflect" on the xap to determine the test provider type. if (unitTestProviderType == UnitTestProviderType.Undefined) { unitTestProviderType = testFileCollection.UnitTestProvider; } if ( (testFileCollection.UnitTestProvider == UnitTestProviderType.MSTest || unitTestProviderType == UnitTestProviderType.MSTest || unitTestProviderType == UnitTestProviderType.MSTestWithCustomProvider) && microsoftTestingFrameworkVersion == null) { microsoftTestingFrameworkVersion = testFileCollection.MSTestVersion; } } }
public StatLightConfiguration GetStatLightConfigurationForXap(UnitTestProviderType unitTestProviderType, string xapPath, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion, Collection<string> methodsToTest, string tagFilters, int numberOfBrowserHosts, bool isRemoteRun, string queryString, WebBrowserType webBrowserType, bool forceBrowserStart, bool showTestingBrowserHost) { if (queryString == null) throw new ArgumentNullException("queryString"); Func<IEnumerable<ITestFile>> filesToCopyIntoHostXap = () => new List<ITestFile>(); string runtimeVersion = null; string entryPointAssembly = string.Empty; if (isRemoteRun) { } else { AssertFileExists(xapPath); var xapReader = new XapReader(_logger); TestFileCollection testFileCollection = xapReader.LoadXapUnderTest(xapPath); runtimeVersion = XapReader.GetRuntimeVersion(xapPath); SetupUnitTestProviderType(testFileCollection, ref unitTestProviderType, ref microsoftTestingFrameworkVersion); entryPointAssembly = testFileCollection.TestAssemblyFullName; filesToCopyIntoHostXap = () => { return xapReader.LoadXapUnderTest(xapPath).FilesContainedWithinXap; }; } var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, methodsToTest, tagFilters, numberOfBrowserHosts, webBrowserType, showTestingBrowserHost, entryPointAssembly); var serverConfig = CreateServerConfiguration( xapPath, clientConfig.UnitTestProviderType, microsoftTestingFrameworkVersion, filesToCopyIntoHostXap, DefaultDialogSmackDownElapseMilliseconds, queryString, forceBrowserStart, showTestingBrowserHost, runtimeVersion); return new StatLightConfiguration(clientConfig, serverConfig); }
public InputOptions SetMicrosoftTestingFrameworkVersion(MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion) { MicrosoftTestingFrameworkVersion = microsoftTestingFrameworkVersion; return this; }
public XapHostType MapToXapHostType(UnitTestProviderType unitTestProviderType, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion, bool isPhoneRun) { Action throwNotSupportedException = () => { throw new NotSupportedException( "Cannot map to a xap host based on the following input values UnitTestProviderType={0}, MicrosoftTestingFrameworkVersion={1}" .FormatWith(unitTestProviderType, microsoftTestingFrameworkVersion)); }; if (isPhoneRun) { switch (unitTestProviderType) { case UnitTestProviderType.MSTest: if (microsoftTestingFrameworkVersion != null && microsoftTestingFrameworkVersion == MicrosoftTestingFrameworkVersion.MSTest2010May) return XapHostType.MSTest2010MayPhone; throwNotSupportedException(); break; case UnitTestProviderType.MSTestWithCustomProvider: throw new NotSupportedException("Could possibly be supported - but just not done yet"); case UnitTestProviderType.UnitDriven: throw new NotSupportedException("Could possibly be supported - but just not done yet"); case UnitTestProviderType.Undefined: default: throwNotSupportedException(); break; } } else { switch (unitTestProviderType) { case UnitTestProviderType.NUnit: case UnitTestProviderType.XUnitLight: return XapHostType.MSTest2010May; case UnitTestProviderType.MSTestWithCustomProvider: case UnitTestProviderType.MSTest: if (microsoftTestingFrameworkVersion.HasValue) { var msTestVersionXapHostStringName = microsoftTestingFrameworkVersion.Value.ToString(); if (Enum.IsDefined(typeof(XapHostType), msTestVersionXapHostStringName)) return (XapHostType)Enum.Parse(typeof(XapHostType), msTestVersionXapHostStringName); } throwNotSupportedException(); break; case UnitTestProviderType.UnitDriven: return XapHostType.UnitDriven2009December; case UnitTestProviderType.XUnit: return XapHostType.XunitContrib2011April; case UnitTestProviderType.Undefined: default: throwNotSupportedException(); break; } } return XapHostType.UnitDriven2009December; }
private ServerTestRunConfiguration CreateServerConfiguration( string xapPath, UnitTestProviderType unitTestProviderType, MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion, IEnumerable<ITestFile> filesToCopyIntoHostXap, long dialogSmackDownElapseMilliseconds, string queryString, bool forceBrowserStart, bool showTestingBrowserHost) { XapHostType xapHostType = _xapHostFileLoaderFactory.MapToXapHostType(unitTestProviderType, microsoftTestingFrameworkVersion); Func<byte[]> hostXapFactory = () => { byte[] hostXap = _xapHostFileLoaderFactory.LoadXapHostFor(xapHostType); hostXap = RewriteXapWithSpecialFiles(hostXap, filesToCopyIntoHostXap); return hostXap; }; return new ServerTestRunConfiguration(hostXapFactory, dialogSmackDownElapseMilliseconds, xapPath, xapHostType, queryString, forceBrowserStart, showTestingBrowserHost); }