StatLight.Core.Configuration.StatLightConfigurationFactory.GetStatLightConfigurationForDll C# (CSharp) Method

GetStatLightConfigurationForDll() private method

private GetStatLightConfigurationForDll ( string dllPath ) : StatLightConfiguration
dllPath string
return StatLightConfiguration
        private StatLightConfiguration GetStatLightConfigurationForDll(string dllPath)
        {
            Func<IEnumerable<ITestFile>> filesToCopyIntoHostXap = () => new List<ITestFile>();
            string entryPointAssembly = string.Empty;
            string runtimeVersion = null;
            IEnumerable<string> testAssemblyFormalNames = new List<string>();

            var dllFileInfo = new FileInfo(dllPath);
            var assemblyResolver = new AssemblyResolver();
            var dependentAssemblies = assemblyResolver.ResolveAllDependentAssemblies(_options.IsPhoneRun, dllFileInfo.FullName);

            var coreFileUnderTest = new TestFile(dllFileInfo.FullName);
            var dependentFilesUnderTest = dependentAssemblies.Select(file => new TestFile(file)).ToList();
            dependentFilesUnderTest.Add(coreFileUnderTest);
            var testFileCollection = new TestFileCollection(_logger,
                                                        AssemblyName.GetAssemblyName(dllFileInfo.FullName).ToString(),
                                                        dependentFilesUnderTest);

            testAssemblyFormalNames = testFileCollection.GetAssemblyNames();

            UnitTestProviderType unitTestProviderType = _options.UnitTestProviderType;
            MicrosoftTestingFrameworkVersion? microsoftTestingFrameworkVersion = _options.MicrosoftTestingFrameworkVersion;

            SetupUnitTestProviderType(testFileCollection, ref unitTestProviderType, ref microsoftTestingFrameworkVersion);

            entryPointAssembly = testFileCollection.TestAssemblyFullName;

            filesToCopyIntoHostXap = () =>
                                        {
                                            return new TestFileCollection(_logger,
                                                                    AssemblyName.GetAssemblyName(dllFileInfo.FullName)
                                                                        .ToString(),
                                                                    dependentFilesUnderTest).FilesContainedWithinXap;
                                        };

            var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, _options.MethodsToTest, _options.TagFilters, _options.NumberOfBrowserHosts, _options.WebBrowserType, entryPointAssembly, _options.WindowGeometry, testAssemblyFormalNames);

            var serverConfig = CreateServerConfiguration(
                dllPath,
                clientConfig.UnitTestProviderType,
                microsoftTestingFrameworkVersion,
                filesToCopyIntoHostXap,
                _options.QueryString,
                _options.ForceBrowserStart,
                _options.WindowGeometry,
                runtimeVersion,
                _options.IsPhoneRun);

            return new StatLightConfiguration(clientConfig, serverConfig);
        }

Usage Example

コード例 #1
0
 private static StatLightConfiguration CreateStatLightConfigurationForDll(StatLightConfigurationFactory configurationFactory, IEnumerable<MethodTask> testMethods, string dllPath)
 {
     return configurationFactory.GetStatLightConfigurationForDll(
         unitTestProviderType: UnitTestProviderType.Undefined, // Let StatLight figure it out
         dllPath: dllPath,
         microsoftTestingFrameworkVersion: null, // Let StatLight figure it out
         methodsToTest: new Collection<string>(testMethods.Select(m => m.GetFullMethodName()).ToList()),
         tagFilters: null,
         numberOfBrowserHosts: 1, // Maybe you spin up 3 or 4 here if you know you're running a ton of tests
         isRemoteRun: false,
         queryString: "", // This is passed to the browser host page (say your test need some configuration - could be passed here - probably not a use case in ReSharper runner)
         webBrowserType: WebBrowserType.SelfHosted,
         forceBrowserStart: false,
         showTestingBrowserHost: false // If you need UI support this needs to be true
     );
 }