Example #1
0
            protected override void Before_all_tests()
            {
                base.Before_all_tests();

                _xapPath = Path.GetTempFileName() + ".zip";

                _filesToCleanup.Add(_xapPath);

                Action <XapZipArchive> addTempFileToZip = (zipFile) =>
                {
                    var pathToTempFileToPlaceInXap = Path.GetTempFileName();
                    using (var writer = File.CreateText(pathToTempFileToPlaceInXap))
                    {
                        writer.Close();
                    }
                    zipFile.AddFile(pathToTempFileToPlaceInXap);
                    _filesToCleanup.Add(pathToTempFileToPlaceInXap);
                };

                using (var zipFile = new XapZipArchive())
                {
                    addTempFileToZip(zipFile);
                    addTempFileToZip(zipFile);
                    addTempFileToZip(zipFile);
                    addTempFileToZip(zipFile);
                    zipFile.Save(_xapPath);
                }

                _testFileCollection = new Core.WebServer.XapInspection.XapReader(new ConsoleLogger(LogChatterLevels.Full)).LoadXapUnderTest(_xapPath);
            }
Example #2
0
            protected override void Before_all_tests()
            {
                base.Before_all_tests();

                string fileName = ProviderTests.TestXapFileLocations.SilverlightIntegrationTests;

                _testFileCollection = new Core.WebServer.XapInspection.XapReader(new ConsoleLogger(LogChatterLevels.Full)).LoadXapUnderTest(fileName);
            }
Example #3
0
            protected override void Before_all_tests()
            {
                base.Before_all_tests();

                string fileName = ProviderTests.TestXapFileLocations.SilverlightIntegrationTests;

                _testFileCollection = new Core.WebServer.XapInspection.XapReader(new ConsoleLogger(LogChatterLevels.Full)).LoadXapUnderTest(fileName);
            }
Example #4
0
        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));
        }
Example #5
0
        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");
            }

            if (showTestingBrowserHost && !Environment.UserInteractive)
            {
                throw new StatLightException("You cannot use the -b option as your C.I. server's agent process is not running in desktop interactive mode.");
            }

            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));
        }
Example #6
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));
        }
Example #7
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));
        }
        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");
            }

            IEnumerable <ITestFile> filesToCopyIntoHostXap = new List <ITestFile>();
            string entryPointAssembly = string.Empty;

            if (isRemoteRun)
            {
            }
            else
            {
                AssertFileExists(xapPath);

                var xapReader = new XapReader(_logger);

                TestFileCollection testFileCollection = xapReader.LoadXapUnderTest(xapPath);

                SetupUnitTestProviderType(testFileCollection, ref unitTestProviderType, ref microsoftTestingFrameworkVersion);

                entryPointAssembly = testFileCollection.TestAssemblyFullName;

                filesToCopyIntoHostXap = testFileCollection.FilesContainedWithinXap;
            }

            var clientConfig = new ClientTestRunConfiguration(unitTestProviderType, methodsToTest, tagFilters, numberOfBrowserHosts, webBrowserType, showTestingBrowserHost, entryPointAssembly);

            var serverConfig = CreateServerConfiguration(
                xapPath,
                clientConfig.UnitTestProviderType,
                microsoftTestingFrameworkVersion,
                filesToCopyIntoHostXap,
                DefaultDialogSmackDownElapseMilliseconds,
                queryString,
                forceBrowserStart,
                showTestingBrowserHost);

            return(new StatLightConfiguration(clientConfig, serverConfig));
        }
        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;
                }
            }
        }
Example #10
0
            protected override void Before_all_tests()
            {
                base.Before_all_tests();

                _xapPath = Path.GetTempFileName() + ".zip";

                _filesToCleanup.Add(_xapPath);

                Action<XapZipArchive> addTempFileToZip = (zipFile) =>
                {
                    var pathToTempFileToPlaceInXap = Path.GetTempFileName();
                    using (var writer = File.CreateText(pathToTempFileToPlaceInXap))
                    {
                        writer.Close();
                    }
                    zipFile.AddFile(pathToTempFileToPlaceInXap);
                    _filesToCleanup.Add(pathToTempFileToPlaceInXap);
                };

                using (var zipFile = new XapZipArchive())
                {
                    addTempFileToZip(zipFile);
                    addTempFileToZip(zipFile);
                    addTempFileToZip(zipFile);
                    addTempFileToZip(zipFile);
                    zipFile.Save(_xapPath);
                }

                _testFileCollection = new Core.WebServer.XapInspection.XapReader(new ConsoleLogger(LogChatterLevels.Full)).LoadXapUnderTest(_xapPath);
            }