public static void ClassInitialize(TestContext testContext) { // // This is called from other tests e.g. DynamicServicesInvokerTest // lock(InitLock) { if(_isInitialized) { return; } Directory.SetCurrentDirectory(testContext.TestDir); _testDir = testContext.TestDir; var workspaceID = Guid.NewGuid(); #region Copy server services to file system var workspacePath = Path.Combine(GlobalConstants.WorkspacePath, workspaceID.ToString()); #region Initialize services _servicesPath = Path.Combine(workspacePath, "Services"); var servicesVersionControlPath = Path.Combine(_servicesPath, "VersionControl"); var serverServicesPath = Path.Combine(_testDir, "Services"); Directory.CreateDirectory(_servicesPath); Directory.CreateDirectory(servicesVersionControlPath); Directory.CreateDirectory(serverServicesPath); var xml = XmlResource.Fetch(ServiceName); xml.Save(Path.Combine(_servicesPath, ServiceName + ".xml")); xml.Save(Path.Combine(servicesVersionControlPath, ServiceName + ".V" + VersionNo + ".xml")); xml.Save(Path.Combine(serverServicesPath, ServiceName + ".xml")); xml = XmlResource.Fetch(ServiceNameUnsigned); xml.Save(Path.Combine(_servicesPath, ServiceNameUnsigned + ".xml")); xml.Save(Path.Combine(servicesVersionControlPath, ServiceNameUnsigned + ".V" + VersionNo + ".xml")); xml.Save(Path.Combine(serverServicesPath, ServiceNameUnsigned + ".xml")); _testServiceDefinition = xml.ToString(); #endregion #region Initialize sources _sourcesPath = Path.Combine(workspacePath, "Sources"); var sourcesVersionControlPath = Path.Combine(_sourcesPath, "VersionControl"); var serverSourcesPath = Path.Combine(_testDir, "Sources"); Directory.CreateDirectory(_sourcesPath); Directory.CreateDirectory(sourcesVersionControlPath); Directory.CreateDirectory(serverSourcesPath); xml = XmlResource.Fetch(SourceName); xml.Save(Path.Combine(_sourcesPath, SourceName + ".xml")); xml.Save(Path.Combine(sourcesVersionControlPath, SourceName + ".V" + VersionNo + ".xml")); xml.Save(Path.Combine(serverSourcesPath, SourceName + ".xml")); _testSourceDefinition = xml.ToString(); xml = XmlResource.Fetch(ServerConnection1Name); xml.Save(Path.Combine(_sourcesPath, ServerConnection1ResourceName + ".xml")); xml.Save(Path.Combine(_sourcesPath, ServerConnection1ResourceName + ".xml")); xml.Save(Path.Combine(sourcesVersionControlPath, ServerConnection1ResourceName + ".V" + VersionNo + ".xml")); xml.Save(Path.Combine(serverSourcesPath, ServerConnection1ResourceName + ".xml")); xml = XmlResource.Fetch(ServerConnection2Name); xml.Save(Path.Combine(_sourcesPath, ServerConnection2ResourceName + ".xml")); xml.Save(Path.Combine(sourcesVersionControlPath, ServerConnection2ResourceName + ".V" + VersionNo + ".xml")); xml.Save(Path.Combine(serverSourcesPath, ServerConnection2ResourceName + ".xml")); #endregion #endregion _workspace = WorkspaceRepository.Instance.Get(workspaceID); _testInstance = WorkspaceRepository.Instance; _isInitialized = true; } }
public static WorkspaceRepository SetupRepo(out Guid workspaceID) { var repo = new WorkspaceRepository(); workspaceID = Guid.NewGuid(); List<IResource> resources; ResourceCatalogTests.SaveResources(Guid.Empty, null, true, true, new string[0], new[] { "Calculate_RecordSet_Subtract" }, out resources, new Guid[0], new[] { Guid.NewGuid() }); ResourceCatalogTests.SaveResources(workspaceID, null, true, true, new string[0], new[] { "Calculate_RecordSet_Subtract" }, out resources, new Guid[0], new[] { Guid.NewGuid() }); // Force reload of server workspace from _currentTestDir ResourceCatalog.Instance.LoadWorkspace(GlobalConstants.ServerWorkspaceID); return repo; }