Exemple #1
0
        protected void SetupAPICallLog()
        {
            string directoryPath  = Path.Combine(Workspace.DataService.DestinationFolder, APICallLog.DirectoryName);
            string markerFilePath = Path.Combine(directoryPath, APICallLog.MarkerFileName);

            if (!this.LogAPICalls)
            {
                AstoriaTestLog.IsFalse(TrustedMethods.IsFileExists(markerFilePath), "Marker file should have been cleaned up by prior request");
                AstoriaTestLog.IsFalse(TrustedMethods.IsDirectoryNotEmpty(directoryPath), "Directory should be empty!");
                return;
            }

            IOUtil.EnsureDirectoryExists(directoryPath);
            IOUtil.CreateEmptyFile(markerFilePath);
        }
Exemple #2
0
        public static void AddSilverlightHostFiles(Workspace workspace)
        {
            Assembly resourceAssembly = workspace.GetType().Assembly;

            string webserviceWorkspaceDir = workspace.DataService != null ? workspace.DataService.DestinationFolder : workspace.HostSourceFolder;
            string webServiceBinDir       = Path.Combine(webserviceWorkspaceDir, "Bin");
            string tempCLRBinDir          = Path.Combine(webserviceWorkspaceDir, "tempCLR");
            string tempSLBinDir           = Path.Combine(webserviceWorkspaceDir, "tempSL");
            string webServiceAppCodeDir   = Path.Combine(webserviceWorkspaceDir, "App_Code");
            string webServiceClientBinDir = Path.Combine(webserviceWorkspaceDir, "ClientBin");

            IOUtil.EnsureDirectoryExists(webServiceClientBinDir);

            IOUtil.FindAndWriteResourceToFile(resourceAssembly, "AstoriaTestSilverlight.svc", Path.Combine(webserviceWorkspaceDir, "AstoriaTestSilverlight.svc"));
            IOUtil.FindAndWriteResourceToFile(resourceAssembly, "AstoriaTestSilverlightService.cs", Path.Combine(webServiceAppCodeDir, "AstoriaTestSilverlightService.cs"));

            if (AstoriaTestProperties.Client == ClientEnum.SILVERLIGHT)
            {
                File.Copy(Path.Combine(Environment.CurrentDirectory, "SilverlightAstoriaTestPage.html"), Path.Combine(webserviceWorkspaceDir, "SilverlightAstoriaTestPage.html"));
                //GenerateSilverlightXAP(resourceAssembly, webserviceWorkspaceDir, tempCLRBinDir, webServiceAppCodeDir, webServiceClientBinDir);
                File.Copy(Path.Combine(Environment.CurrentDirectory, "SilverlightAstoriaTest.xap"), Path.Combine(webServiceClientBinDir, "SilverlightAstoriaTest.xap"));
            }
        }
Exemple #3
0
        private void CopyServiceFiles()
        {
            Assembly resourceAssembly = this.GetType().Assembly;

            IOUtil.EnsureDirectoryExists(DestinationFolder);
            IOUtil.EmptyDirectoryRecusively(DestinationFolder);

            string serviceSourceCodePath = Path.Combine(DestinationFolder, _serviceName + ".cs");

            StringBuilder serviceSource = new StringBuilder();

            serviceSource.AppendLine(this.Workspace.BuildDataServiceClassUsings());
            serviceSource.AppendLine("namespace CustomTestServiceHost");
            serviceSource.AppendLine("{");
            serviceSource.AppendLine(this.Workspace.BuildDataServiceClassCode());
            serviceSource.AppendLine("}");

            File.WriteAllText(serviceSourceCodePath, serviceSource.ToString());

            this.Workspace.PopulateHostSourceFolder();

            // copy additional files
            foreach (string file in this.Workspace.ServiceHostFiles())
            {
                File.Copy(file, Path.Combine(DestinationFolder, Path.GetFileName(file)));

                if (file.Contains("Edm.ObjectLayer"))
                {
                    string copiedFile = Path.Combine(DestinationFolder, Path.GetFileName(file));
                    string fileText   = File.ReadAllText(copiedFile);

                    string pathAndName = Path.Combine(DestinationFolder, this.Workspace.Name);

                    System.Data.EntityClient.EntityConnectionStringBuilder connBuilder = new System.Data.EntityClient.EntityConnectionStringBuilder();
                    connBuilder.ProviderConnectionString = this.Workspace.Database.DatabaseConnectionString;
                    connBuilder.Metadata = pathAndName + ".csdl|" + pathAndName + ".ssdl|" + pathAndName + ".msl";
                    connBuilder.Provider = "System.Data.SqlClient";

                    string connString = connBuilder.ToString();
                    connString = connString.Replace(@"\", @"\\");
                    connString = connString.Replace("\"", "\\\"");

                    string modifiedText = fileText.Replace("name=" + this.Workspace.ContextTypeName, connString);

                    File.WriteAllText(copiedFile, modifiedText);
                }
            }

#if false // pulled from GAC - not local filesystem
            // Copy Microsoft.OData.Service.dll and test framework
            if (!AstoriaTestProperties.SetupRunOnWebServer)
            {
                if (AstoriaTestProperties.Host != Host.Debug)
                {
                    File.Copy(Path.Combine(Path.GetDirectoryName(resourceAssembly.Location), DataFxAssemblyRef.File.DataServices), Path.Combine(DestinationFolder, DataFxAssemblyRef.File.DataServices));
                }
                else
                {
                    File.Copy(Path.Combine(TestUtil.GreenBitsReferenceAssembliesDirectory, DataFxAssemblyRef.File.DataServices), Path.Combine(DestinationFolder, DataFxAssemblyRef.File.DataServices));
                }
                if (AstoriaTestProperties.Host != Host.Debug)
                {
                    File.Copy(Path.Combine(Path.GetDirectoryName(resourceAssembly.Location), DataFxAssemblyRef.File.DataServicesClient), Path.Combine(DestinationFolder, DataFxAssemblyRef.File.DataServicesClient));
                }
                else
                {
                    File.Copy(Path.Combine(TestUtil.GreenBitsReferenceAssembliesDirectory, DataFxAssemblyRef.File.DataServicesClient), Path.Combine(DestinationFolder, DataFxAssemblyRef.File.DataServicesClient));
                }
            }
#endif

            // TODO: cannot get rid of framework DLL for client SKU
            // File.Copy(resourceAssembly.Location, Path.Combine(hostFolder, Path.GetFileName(resourceAssembly.Location)));
            CopyServerWorkspaceFiles(DestinationFolder);
        }
Exemple #4
0
        private void CopyServiceFiles()
        {
            Assembly resourceAssembly = this.GetType().Assembly;

#if !ClientSKUFramework
            IOUtil.EnsureDirectoryExists(DestinationFolder);
            IOUtil.EmptyDirectoryRecusively(DestinationFolder);
#endif
            string serviceSource;
            if (AstoriaTestProperties.Host == Host.IDSH || AstoriaTestProperties.Host == Host.IDSH2)
            {
                serviceSource = "IDataServiceHostRunner";
            }
            else
            {
                serviceSource = "TestServiceHost";
            }

            string serviceSourceCodePath = Path.Combine(DestinationFolder, serviceName + ".cs");
            IOUtil.FindAndWriteResourceToFile(resourceAssembly, serviceSource + ".cs", serviceSourceCodePath);

            string sourceText = File.ReadAllText(serviceSourceCodePath);
            sourceText = sourceText.Replace("//[[Usings]]", this.Workspace.BuildDataServiceClassUsings());
            sourceText = sourceText.Replace("//[[ServiceCode]]", this.Workspace.BuildDataServiceClassCode());
            File.WriteAllText(serviceSourceCodePath, sourceText);

            // copy additional files
            foreach (string file in this.Workspace.ServiceHostFiles())
            {
                string newPath = file.Replace(Workspace.HostSourceFolder, DestinationFolder);
                IOUtil.EnsureDirectoryExists(Path.GetDirectoryName(newPath));
                File.Copy(file, newPath);
            }

            var assembliesToCopy = new List <Assembly>
            {
                typeof(FullTrust.TrustedMethods).Assembly, // this is a special case for the fully-trusted-methods assembly, which must always be copied
                typeof(Microsoft.Spatial.ISpatial).Assembly,
                typeof(Microsoft.OData.Edm.IEdmModel).Assembly,
                typeof(Microsoft.OData.Core.ODataException).Assembly,
#if !ClientSKUFramework
                typeof(Microsoft.OData.Service.DataService <>).Assembly,
#endif
                typeof(Microsoft.OData.Client.DataServiceContext).Assembly,
            };

            foreach (var assembly in assembliesToCopy)
            {
                File.Copy(assembly.Location, Path.Combine(DestinationFolder, Path.GetFileName(assembly.Location)));
            }

            // TODO: cannot get rid of precompiled library for the client SKU
            // File.Copy(resourceAssembly.Location, Path.Combine(hostFolder, Path.GetFileName(resourceAssembly.Location)));
            CopyServerWorkspaceFiles(DestinationFolder);

            // Copy win7 manifest file if test flag is set
            if (AstoriaTestProperties.WindowsCompatFlag == WindowsCompatFlag.Win7)
            {
                string serviceManifestPath = Path.Combine(DestinationFolder, serviceName + ".exe.manifest");
                IOUtil.FindAndWriteResourceToFile(resourceAssembly, serviceSource + ".exe.manifest", serviceManifestPath);
            }
        }