Ejemplo n.º 1
0
        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));
        }
Ejemplo n.º 2
0
        private StatLightConfiguration GetStatLightConfigurationForXap(string xapPath)
        {
            Func <IEnumerable <ITestFile> > filesToCopyIntoHostXap = () => new List <ITestFile>();
            string runtimeVersion = null;
            IEnumerable <string> testAssemblyFormalNames = new List <string>();
            string entryPointAssembly = string.Empty;

            var xapReader = new XapReader(_logger);

            TestFileCollection testFileCollection = xapReader.LoadXapUnderTest(xapPath);

            runtimeVersion = XapReader.GetRuntimeVersion(xapPath);

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

            SetupUnitTestProviderType(testFileCollection, ref unitTestProviderType, ref microsoftTestingFrameworkVersion);

            entryPointAssembly      = testFileCollection.TestAssemblyFullName;
            testAssemblyFormalNames = testFileCollection.GetAssemblyNames();

            filesToCopyIntoHostXap = () =>
            {
                return(xapReader.LoadXapUnderTest(xapPath).FilesContainedWithinXap);
            };

            var clientConfig = new ClientTestRunConfiguration(
                unitTestProviderType: unitTestProviderType,
                methodsToTest: _options.MethodsToTest,
                tagFilters: _options.TagFilters,
                numberOfBrowserHosts: _options.NumberOfBrowserHosts,
                webBrowserType: _options.WebBrowserType,
                entryPointAssembly: entryPointAssembly,
                windowGeometry: _options.WindowGeometry,
                testAssemblyFormalNames: testAssemblyFormalNames);

            var serverConfig = CreateServerConfiguration(
                xapPath,
                unitTestProviderType,
                microsoftTestingFrameworkVersion,
                filesToCopyIntoHostXap,
                _options.QueryString,
                _options.ForceBrowserStart,
                _options.WindowGeometry,
                runtimeVersion,
                _options.IsPhoneRun);

            return(new StatLightConfiguration(clientConfig, serverConfig));
        }