internal static Federation CreateFederation(string root, TestContent content) { string contentDir = Path.Combine(Path.GetFullPath(root), "WikiBases"); if (Directory.Exists(contentDir)) { Directory.Delete(contentDir, true); } Directory.CreateDirectory(contentDir); TestUtilities.SetDirectoryWebWritable(contentDir); FederationConfiguration configuration = new FederationConfiguration(); FileSystemNamespaceProvider provider = new FileSystemNamespaceProvider(); bool defaultNamespaceSpecified = false; foreach (TestNamespace ns in content.Namespaces) { provider.Root = Path.Combine(contentDir, ns.Name); provider.Namespace = ns.Name; NamespaceProviderDefinition definition = new NamespaceProviderDefinition(); definition.Id = Guid.NewGuid().ToString(); provider.SavePersistentParametersToDefinition(definition); definition.Type = provider.GetType().FullName; definition.AssemblyName = provider.GetType().Assembly.FullName; configuration.NamespaceMappings.Add(definition); // We always set the first namespace to be the default one if (defaultNamespaceSpecified == false) { configuration.DefaultNamespace = ns.Name; defaultNamespaceSpecified = true; } } string configFilePath = TestUtilities.ReadConfigFilePath(); configuration.WriteToFile(configFilePath); Federation federation = new Federation(OutputFormat.HTML, new LinkMaker(TestUtilities.BaseUrl)); federation.LoadFromConfiguration(configuration); foreach (TestNamespace ns in content.Namespaces) { FlexWiki.ContentBase contentBase = federation.ContentBaseForNamespace(ns.Name); foreach (TestTopic topic in ns.Topics) { LocalTopicName name = new LocalTopicName(topic.Name); foreach (string text in topic.ContentHistory) { name.Version = FlexWiki.AbsoluteTopicName.NewVersionStringForUser("BuildVerificationTests"); contentBase.WriteTopicAndNewVersion(name, text); //CA We need to sleep a little while so we don't try to write two topics //CA within the same time slice, or they get the same version name. System.Threading.Thread.Sleep(30); } } } RestartWebApplication(); return federation; }