Ejemplo n.º 1
0
        protected override void Before_all_tests()
        {
            base.Before_all_tests();

            _xapRewriter = new XapRewriter(base.TestLogger);

            var appManifest = @"<Deployment xmlns=""http://schemas.microsoft.com/client/2007/deployment"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" EntryPointAssembly=""StatLight.Client.Harness"" EntryPointType=""StatLight.Client.Harness.App"" RuntimeVersion=""4.0.50826.0"">
              <Deployment.Parts>
            <AssemblyPart x:Name=""StatLight.Client.Harness"" Source=""StatLight.Client.Harness.dll"" />
            <AssemblyPart x:Name=""System.Windows.Controls"" Source=""System.Windows.Controls.dll"" />
            <AssemblyPart x:Name=""System.Xml.Linq"" Source=""System.Xml.Linq.dll"" />
            <AssemblyPart x:Name=""System.Xml.Serialization"" Source=""System.Xml.Serialization.dll"" />
            <AssemblyPart x:Name=""Microsoft.Silverlight.Testing"" Source=""Microsoft.Silverlight.Testing.dll"" />
            <AssemblyPart x:Name=""Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight"" Source=""Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll"" />
              </Deployment.Parts>
            </Deployment>
            ";

            _originalXapHost = new ZipFile();
            _originalXapHost.AddEntry("AppManifest.xaml", "/", appManifest);
            _originalXapHost.AddEntry("StatLight.Client.Harness.dll", "/", new byte[] { 1, 2 });
            _originalXapHost.AddEntry("StatLight.Client.Harness.MSTest.dll", "/", new byte[] { 1, 2 });
            _originalXapHost.AddEntry("System.Windows.Controls.dll", "/", new byte[] { 1, 2 });
            _originalXapHost.AddEntry("System.Xml.Linq.dll", "/", new byte[] { 1, 2 });
            _originalXapHost.AddEntry("System.Xml.Serialization.dll", "/", new byte[] { 1, 2 });
            _originalXapHost.AddEntry("Microsoft.Silverlight.Testing.dll", "/", new byte[] { 1, 2 });
            _originalXapHost.AddEntry("Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll", "/", new byte[] { 1, 2 });

            string originalXapHostFileName = Path.GetTempFileName();
            _originalXapHost.Save(originalXapHostFileName);

            var appManifest2 = @"<Deployment xmlns=""http://schemas.microsoft.com/client/2007/deployment"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" EntryPointAssembly=""StatLight.IntegrationTests.Silverlight.MSTest"" EntryPointType=""StatLight.IntegrationTests.Silverlight.App"" RuntimeVersion=""4.0.50826.0"">
              <Deployment.Parts>
            <AssemblyPart x:Name=""StatLight.IntegrationTests.Silverlight.MSTest"" Source=""StatLight.IntegrationTests.Silverlight.MSTest.dll"" />
            <AssemblyPart x:Name=""Microsoft.Silverlight.Testing"" Source=""Microsoft.Silverlight.Testing.dll"" />
            <AssemblyPart x:Name=""Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight"" Source=""Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll"" />
              </Deployment.Parts>
            </Deployment>
            ";

            _originalXapUnderTest = new ZipFile();
            _originalXapUnderTest.AddEntry("AppManifest.xaml", "/", appManifest2);
            _originalXapUnderTest.AddEntry("StatLight.IntegrationTests.Silverlight.MSTest.dll", "/", new byte[] { 1, 2 });
            _originalXapUnderTest.AddEntry("Microsoft.Silverlight.Testing.dll", "/", new byte[] { 1, 2 });
            _originalXapUnderTest.AddEntry("Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll", "/", new byte[] { 1, 2 });
            _originalXapUnderTest.AddEntry("Test.xml", "Test/Test", "Hello");

            // This was a crazy case that the Sterling db project exposed to StatLight (They had duplicate test assemblies)
            _originalXapUnderTest.AddEntry("Microsoft.Silverlight.Testing.dll", "/Binaries/", new byte[] { 1, 2 });
            _originalXapUnderTest.AddEntry("Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll", "/Binaries/", new byte[] { 1, 2 });

            string originalXapUnderTestFileName = Path.GetTempFileName();
            _originalXapUnderTest.Save(originalXapUnderTestFileName);

            _expectedAppManifest = @"<Deployment xmlns=""http://schemas.microsoft.com/client/2007/deployment"" xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml"" EntryPointAssembly=""StatLight.Client.Harness"" EntryPointType=""StatLight.Client.Harness.App"" RuntimeVersion=""4.0.50826.0"">
              <Deployment.Parts>
            <AssemblyPart x:Name=""StatLight.Client.Harness"" Source=""StatLight.Client.Harness.dll"" />
            <AssemblyPart x:Name=""System.Windows.Controls"" Source=""System.Windows.Controls.dll"" />
            <AssemblyPart x:Name=""System.Xml.Linq"" Source=""System.Xml.Linq.dll"" />
            <AssemblyPart x:Name=""System.Xml.Serialization"" Source=""System.Xml.Serialization.dll"" />
            <AssemblyPart x:Name=""Microsoft.Silverlight.Testing"" Source=""Microsoft.Silverlight.Testing.dll"" />
            <AssemblyPart x:Name=""Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight"" Source=""Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll"" />
            <AssemblyPart x:Name=""StatLight.IntegrationTests.Silverlight.MSTest"" Source=""StatLight.IntegrationTests.Silverlight.MSTest.dll"" />
              </Deployment.Parts>
            </Deployment>
            ";
            _expectedXapHost = new ZipFile();
            _expectedXapHost.AddEntry("StatLight.Client.Harness.dll", "/", new byte[] { 1, 2 });
            _expectedXapHost.AddEntry("StatLight.Client.Harness.MSTest.dll", "/", new byte[] { 1, 2 });
            _expectedXapHost.AddEntry("System.Windows.Controls.dll", "/", new byte[] { 1, 2 });
            _expectedXapHost.AddEntry("System.Xml.Linq.dll", "/", new byte[] { 1, 2 });
            _expectedXapHost.AddEntry("System.Xml.Serialization.dll", "/", new byte[] { 1, 2 });
            _expectedXapHost.AddEntry("Microsoft.Silverlight.Testing.dll", "/", new byte[] { 1, 2 });
            _expectedXapHost.AddEntry("Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll", "/", new byte[] { 1, 2 });
            _expectedXapHost.AddEntry("StatLight.IntegrationTests.Silverlight.MSTest.dll", "/", new byte[] { 1, 2 });
            _expectedXapHost.AddEntry("Test.xml", "Test/Test", "Hello");
            _expectedXapHost.AddEntry("AppManifest.xaml", "/", _expectedAppManifest);

            // This was a crazy case that the Sterling db project exposed to StatLight (They had duplicate test assemblies)
            _expectedXapHost.AddEntry("Microsoft.Silverlight.Testing.dll", "/Binaries/", new byte[] { 1, 2 });
            _expectedXapHost.AddEntry("Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll", "/Binaries/", new byte[] { 1, 2 });

            string expectedXapHostFileName = Path.GetTempFileName();
            _expectedXapHost.Save(expectedXapHostFileName);
        }
        private byte[] RewriteXapWithSpecialFiles(byte[] xapHost, Func<IEnumerable<ITestFile>> filesToCopyIntoHostXapFunc, string runtimeVersion)
        {
            var files = filesToCopyIntoHostXapFunc();
            if (files.Any())
            {
                var rewriter = new XapRewriter(_logger);

                xapHost = rewriter.RewriteZipHostWithFiles(xapHost, files, runtimeVersion)
                                .ToByteArray();
            }

            return xapHost;
        }
        private byte[] RewriteXapWithSpecialFiles(byte[] xapHost, IEnumerable<ITestFile> filesToCopyIntoHostXap)
        {
            if (filesToCopyIntoHostXap.Any())
            {
                var rewriter = new XapRewriter(_logger);

                xapHost = rewriter.RewriteZipHostWithFiles(xapHost, filesToCopyIntoHostXap)
                                .ToByteArray();
            }

            return xapHost;
        }