getPage() 공개 메소드

public getPage ( string blog_id, string page_id, string username, string password ) : Subtext.Framework.XmlRpc.Post
blog_id string
page_id string
username string
password string
리턴 Subtext.Framework.XmlRpc.Post
예제 #1
0
        public void GetPage_ReturnsPostWithhCorrectEntrUrl()
        {
            //arrange
            var repository = new DatabaseObjectProvider();
            string hostname = UnitTestHelper.GenerateUniqueString();
            repository.CreateBlog("", "username", "password", hostname, "");
            UnitTestHelper.SetHttpContextWithBlogRequest(hostname, "");
            BlogRequest.Current.Blog = repository.GetBlog(hostname, "");
            Config.CurrentBlog.AllowServiceAccess = true;

            var urlHelper = new Mock<BlogUrlHelper>();
            urlHelper.Setup(u => u.EntryUrl(It.IsAny<Entry>())).Returns("/entry/whatever");
            var subtextContext = new Mock<ISubtextContext>();
            subtextContext.Setup(c => c.Blog).Returns(Config.CurrentBlog);
            //TODO: FIX!!!
            subtextContext.Setup(c => c.Repository).Returns(repository);
            subtextContext.Setup(c => c.ServiceLocator).Returns(new Mock<IDependencyResolver>().Object);
            subtextContext.Setup(c => c.UrlHelper).Returns(urlHelper.Object);

            var api = new MetaWeblog(subtextContext.Object);
            string category1Name = UnitTestHelper.GenerateUniqueString();
            string category2Name = UnitTestHelper.GenerateUniqueString();
            UnitTestHelper.CreateCategory(Config.CurrentBlog.Id, category1Name);
            UnitTestHelper.CreateCategory(Config.CurrentBlog.Id, category2Name);

            var entry = new Entry(PostType.Story);
            entry.Title = "Title 1";
            entry.Body = "Blah";
            entry.IsActive = true;
            entry.IncludeInMainSyndication = true;
            entry.DateCreatedUtc =
                entry.DatePublishedUtc =
                entry.DateModifiedUtc = DateTime.ParseExact("1975/01/23", "yyyy/MM/dd", CultureInfo.InvariantCulture, DateTimeStyles.AssumeUniversal).ToUniversalTime();
            entry.Categories.Add(category1Name);
            int entryId = UnitTestHelper.Create(entry);
            string enclosureUrl = "http://perseus.franklins.net/hanselminutes_0107.mp3";
            string enclosureMimeType = "audio/mp3";
            long enclosureSize = 26707573;

            FrameworkEnclosure enc =
                UnitTestHelper.BuildEnclosure("<Digital Photography Explained (for Geeks) with Aaron Hockley/>",
                                              enclosureUrl, enclosureMimeType, entryId, enclosureSize, true, true);
            repository.Create(enc);

            //act
            Post post = api.getPage(Config.CurrentBlog.Id.ToString(), entryId.ToString(), "username", "password");

            //assert
            Assert.AreEqual(1, post.categories.Length);
            Assert.AreEqual("http://" + hostname + "/entry/whatever", post.link);
            Assert.AreEqual("http://" + hostname + "/entry/whatever", post.permalink);
            Assert.AreEqual(category1Name, post.categories[0]);
            Assert.AreEqual(enclosureUrl, post.enclosure.Value.url);
            Assert.AreEqual(enclosureMimeType, post.enclosure.Value.type);
            Assert.AreEqual(enclosureSize, post.enclosure.Value.length);
        }