예제 #1
0
        public void Contents_PageWithTalkPage_ManyParameterChanges_CorrectContent()
        {
            // Log in as ADMIN
            Plug p = Utils.BuildPlugForAdmin();

            // Create a page with some content and save edittime
            string       path    = PageUtils.GenerateUniquePageName();
            string       content = "test content";
            string       title   = "test title";
            string       comment = "new page!";
            MimeType     mime    = MimeType.TEXT_UTF8;
            DreamMessage msg     = p.At("pages", "=" + XUri.DoubleEncode(path), "contents")
                                   .With("title", title)
                                   .With("comment", comment)
                                   .Post(DreamMessage.Ok(mime, content), new Result <DreamMessage>()).Wait();

            Assert.AreEqual(DreamStatus.Ok, msg.Status, "Creating page failed");
            msg = PageUtils.GetPage(p, path);
            string edittime = msg.ToDocument()["date.edited"].AsText;

            Assert.IsNotNull(edittime, "No date.edited in page document!");

            // Create a talk page
            string talkid;
            string talkpath;

            PageUtils.CreateTalkPage(p, path, out talkid, out talkpath);

            // Now make some changes
            string lang = "de";

            content = "new test content!";
            comment = "edit page!";
            title   = "new title!";
            mime    = MimeType.TEXT;
            msg     = p.At("pages", "=" + XUri.DoubleEncode(path), "contents")
                      .With("title", title)
                      .With("comment", comment)
                      .With("language", lang)
                      .With("edittime", edittime)
                      .Post(DreamMessage.Ok(mime, content), new Result <DreamMessage>()).Wait();
            Assert.AreEqual(DreamStatus.Ok, msg.Status, "Editing page contents failed");

            // Verify changes
            msg = PageUtils.GetPage(p, path);
            Assert.AreEqual(title, msg.ToDocument()["title"].AsText ?? String.Empty, "Unexpected title");
            Assert.AreEqual(content, msg.ToDocument()["summary"].AsText ?? String.Empty, "Unexpected content");
            Assert.AreEqual(lang, msg.ToDocument()["properties/language"].AsText ?? String.Empty, "Unexpected language");
            Assert.AreEqual(comment + "; "
                            + "2 words added; "
                            + "page display name changed to '" + title + "'; "
                            + "page language changed to Deutsch", msg.ToDocument()["description"].AsText ?? String.Empty, "Unexpected description");
        }