public void SimpleReadingAndWritingTest() { LocalTopicName an = new LocalTopicName("SimpleReadingAndWritingTest"); string c = @"Hello There"; ContentBase().WriteTopic(an, c); string ret; using (TextReader sr = ContentBase().TextReaderForTopic(an)) { ret = sr.ReadToEnd(); } Assert.AreEqual(c, ret); ContentBase().DeleteTopic(an); Assert.IsTrue(!ContentBase().TopicExistsLocally(an)); }
public void LatestVersionForTopic() { string author = "LatestVersionForTopicTest"; WriteTestTopicAndNewVersion(_base, "TopicOne", @"A Change", author); WriteTestTopicAndNewVersion(_base, "TopicTwo", @"A Change", author); WriteTestTopicAndNewVersion(_base, "TopicThree", @"A Change", author); ContentBase cb = ContentBase(); LocalTopicName atn1 = new LocalTopicName("TopicOne"); LocalTopicName atn2 = new LocalTopicName("TopicTwo"); LocalTopicName atn3 = new LocalTopicName("TopicThree"); IEnumerable versions1 = cb.AllVersionsForTopic(atn1); IEnumerable versions2 = cb.AllVersionsForTopic(atn2); IEnumerable versions3 = cb.AllVersionsForTopic(atn3); string version1 = null; string version2 = null; string version3 = null; foreach (AbsoluteTopicName atn in versions1) { version1 = atn.Version; break; } foreach (AbsoluteTopicName atn in versions2) { version2 = atn.Version; break; } foreach (AbsoluteTopicName atn in versions3) { version3 = atn.Version; break; } Assert.AreEqual(version1, cb.LatestVersionForTopic(atn1), "Checking that latest version is calculated correctly"); Assert.AreEqual(version2, cb.LatestVersionForTopic(atn2), "Checking that latest version is calculated correctly"); Assert.AreEqual(version3, cb.LatestVersionForTopic(atn3), "Checking that latest version is calculated correctly"); }
public void RenameAndVerifyVersionsGetRenamedTest() { LocalTopicName name1 = new LocalTopicName("TopicOne"); LocalTopicName name2 = new LocalTopicName("TopicOneRenamed"); ContentBase().RenameTopic(name1, name2.Name, false); int c = 0; foreach (object x in ContentBase().AllVersionsForTopic(name2)) { x.ToString(); // do something with x just to shut the compiler up c++; } Assert.AreEqual(c, 4); // should be 4 versions, even after rename }
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; }