当前位置: 首页>>代码示例>>C#>>正文


C# Framework.Blog类代码示例

本文整理汇总了C#中Subtext.Framework.Blog的典型用法代码示例。如果您正苦于以下问题:C# Blog类的具体用法?C# Blog怎么用?C# Blog使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Blog类属于Subtext.Framework命名空间,在下文中一共展示了Blog类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CanInsertNewMetaTag

        public void CanInsertNewMetaTag(string content, string name, string httpEquiv, bool withEntry, string errMsg)
        {
            blog = UnitTestHelper.CreateBlogAndSetupContext();

            int? entryId = null;
            if(withEntry)
            {
                Entry e = UnitTestHelper.CreateEntryInstanceForSyndication("Steven Harman", "My Post", "Foo Bar Zaa!");
                entryId = UnitTestHelper.Create(e);
            }

            MetaTag mt = UnitTestHelper.BuildMetaTag(content, name, httpEquiv, blog.Id, entryId, DateTime.Now);

            // make sure there are no meta-tags for this blog in the data store
            ICollection<MetaTag> tags = MetaTags.GetMetaTagsForBlog(blog, 0, 100);
            Assert.AreEqual(0, tags.Count, "Should be zero MetaTags.");

            // add the meta-tag to the data store
            int tagId = MetaTags.Create(mt);

            tags = MetaTags.GetMetaTagsForBlog(blog, 0, 100);

            Assert.AreEqual(1, tags.Count, errMsg);

            MetaTag newTag = tags.First();

            // make sure all attributes of the meta-tag were written to the data store correctly.
            Assert.AreEqual(tagId, newTag.Id, "Wrong Id");
            Assert.AreEqual(mt.Content, newTag.Content, "Wrong content");
            Assert.AreEqual(mt.Name, newTag.Name, "wrong name attribute");
            Assert.AreEqual(mt.HttpEquiv, newTag.HttpEquiv, "Wrong http-equiv attriubte");
            Assert.AreEqual(mt.BlogId, newTag.BlogId, "Wrong blogId");
            Assert.AreEqual(mt.EntryId, newTag.EntryId, "Wrong entryId");
            Assert.AreEqual(mt.DateCreated.Date, newTag.DateCreated.Date, "Wrong created date");
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:35,代码来源:MetaTagInsertTests.cs

示例2: GetReturnsZeroWhenNoMetaTagsExistForBlog

 public void GetReturnsZeroWhenNoMetaTagsExistForBlog()
 {
     var repository = new DatabaseObjectProvider();
     blog = UnitTestHelper.CreateBlogAndSetupContext();
     Assert.AreEqual(0, repository.GetMetaTagsForBlog(blog, 0, 100).Count,
                     "Shouldn't have found any MetaTags for this blog.");
 }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:7,代码来源:MetaTagGetTests.cs

示例3: GetArchiveCategories

        protected ICollection<LinkCategory> GetArchiveCategories(Blog blog)
        {
            var linkCategories = new List<LinkCategory>();

            // we want to make sure that the LinkCategory is NOT null before we add it to the collection.
            LinkCategory category = Repository.Links(CategoryType.PostCollection, blog, Url);
            if (category != null)
            {
                linkCategories.Add(category);
            }
            category = Repository.Links(CategoryType.StoryCollection, blog, Url);
            if (category != null)
            {
                linkCategories.Add(category);
            }
            category = Repository.ArchiveMonth(Url, blog);
            if (category != null)
            {
                linkCategories.Add(category);
            }
            category = Repository.Links(CategoryType.ImageCollection, blog, Url);
            if (category != null)
            {
                linkCategories.Add(category);
            }
            return linkCategories;
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:27,代码来源:ArchiveLinks.cs

示例4: NameValueCollection

        public void RequestNotMatchingAnyBlog_ButWithASingleBlogInSystemWithLocalHostButNotMatchingSubfolder_ReturnsUpdatesItsHostThenRedirectsToSubfolder()
        {
            //arrange
            var onlyBlog = new Blog { Host = "localhost", Subfolder = "sub" };
            var pagedCollection = new PagedCollection<Blog> { onlyBlog };
            pagedCollection.MaxItems = 1;

            var repository = new Mock<ObjectRepository>();
            repository.Setup(r => r.GetBlog("example.com", It.IsAny<string>())).Returns((Blog)null);
            repository.Setup(r => r.GetPagedBlogs(null, 0, It.IsAny<int>(), ConfigurationFlags.None)).Returns(
                pagedCollection);
            var appSettings = new NameValueCollection();
            appSettings.Add("AggregateEnabled", "false");
            var hostInfo = new HostInfo(appSettings);
            var service = new BlogLookupService(repository.Object, new LazyNotNull<HostInfo>(() => hostInfo));
            var blogRequest = new BlogRequest("example.com", string.Empty, new Uri("http://example.com/foo/bar"), false);

            //act
            BlogLookupResult result = service.Lookup(blogRequest);

            //assert
            Assert.IsNull(result.Blog);
            Assert.IsNotNull(result.AlternateUrl);
            Assert.AreEqual("http://example.com/sub/foo/bar", result.AlternateUrl.ToString());
            Assert.AreEqual("example.com", onlyBlog.Host);
            repository.Verify(r => r.UpdateBlog(It.IsAny<Blog>()));
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:27,代码来源:BlogLookupServiceTests.cs

示例5: editPost_WithEntryHavingEnclosure_UpdatesEntryEnclosureWithNewEnclosure

        public void editPost_WithEntryHavingEnclosure_UpdatesEntryEnclosureWithNewEnclosure()
        {
            //arrange
            var entry = new Entry(PostType.BlogPost) { Title = "Title 1", Body = "Blah", IsActive = true };
            entry.DateCreatedUtc = entry.DatePublishedUtc = entry.DateModifiedUtc = DateTime.ParseExact("1975/01/23", "yyyy/MM/dd", CultureInfo.InvariantCulture);
            entry.Categories.Add("TestCategory");
            var blog = new Blog { Id = 123, Host = "localhost", AllowServiceAccess = true, UserName = "username", Password = "password" };
            var subtextContext = new Mock<ISubtextContext>();
            subtextContext.Setup(c => c.Blog).Returns(blog);
            subtextContext.Setup(c => c.Repository.GetEntry(It.IsAny<Int32>(), false, true)).Returns(entry);
            var entryPublisher = new Mock<IEntryPublisher>();
            Entry publishedEntry = null;
            entryPublisher.Setup(p => p.Publish(It.IsAny<Entry>())).Callback<Entry>(e => publishedEntry = e);
            FrameworkEnclosure enclosure = UnitTestHelper.BuildEnclosure("<Digital Photography Explained (for Geeks) with Aaron Hockley/>",
                                              "http://perseus.franklins.net/hanselminutes_0107.mp3", "audio/mp3", 123, 26707573, true, true);
            entry.Enclosure = enclosure;
            var post = new Post { title = "Title 2", description = "Blah", dateCreated = DateTime.UtcNow };

            var postEnclosure = new Enclosure
            {
                url = "http://codeclimber.net.nz/podcast/mypodcastUpdated.mp3",
                type = "audio/mp3",
                length = 123456789
            };
            post.enclosure = postEnclosure;
            var metaWeblog = new MetaWeblog(subtextContext.Object, entryPublisher.Object);

            // act
            bool result = metaWeblog.editPost("123", "username", "password", post, true);

            // assert
            Assert.IsTrue(result);
            Assert.IsNotNull(publishedEntry.Enclosure);
            Assert.AreEqual("http://codeclimber.net.nz/podcast/mypodcastUpdated.mp3", entry.Enclosure.Url);
        }
开发者ID:junxy,项目名称:subtext_src,代码行数:35,代码来源:MetaBlogApiTests.cs

示例6: ConvertBlogPost

        public Entry ConvertBlogPost(BlogMLPost post, BlogMLBlog blogMLBlog, Blog blog)
        {
            DateTime dateModified = blog != null ? blog.TimeZone.FromUtc(post.DateModified) : post.DateModified;
            DateTime dateCreated = blog != null ? blog.TimeZone.FromUtc(post.DateCreated) : post.DateCreated;

            var newEntry = new Entry((post.PostType == BlogPostTypes.Article) ? PostType.Story : PostType.BlogPost)
            {
                Title = GetTitleFromPost(post).Left(BlogPostTitleMaxLength),
                DateCreated = dateCreated,
                DateModified = dateModified,
                DateSyndicated = post.Approved ? dateModified : DateTime.MaxValue,
                Body = post.Content.UncodedText,
                IsActive = post.Approved,
                DisplayOnHomePage = post.Approved,
                IncludeInMainSyndication = post.Approved,
                IsAggregated = post.Approved,
                AllowComments = true,
                Description = post.HasExcerpt ? post.Excerpt.UncodedText: null
            };

            if(!string.IsNullOrEmpty(post.PostName))
            {
                newEntry.EntryName = post.PostName;
            }
            else
            {
                SetEntryNameForBlogspotImport(post, newEntry);
            }

            SetEntryAuthor(post, newEntry, blogMLBlog);

            SetEntryCategories(post, newEntry, blogMLBlog);
            return newEntry;
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:34,代码来源:BlogMLImportMapper.cs

示例7: CanGetHashCode

        public void CanGetHashCode()
        {
            var blog = new Blog();
            blog.Host = "http://subtextproject.com";
            blog.Subfolder = "blog";

            Assert.AreNotEqual(0, blog.GetHashCode());
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:8,代码来源:BlogInfoTests.cs

示例8: CanSetFeedBurnerName

        public void CanSetFeedBurnerName()
        {
            var blog = new Blog();
            blog.RssProxyUrl = null;
            Assert.IsFalse(blog.RssProxyEnabled);

            blog.RssProxyUrl = "Subtext";
            Assert.IsTrue(blog.RssProxyEnabled);
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:9,代码来源:BlogInfoTests.cs

示例9: CommentRssWriterProducesValidEmptyFeed

        public void CommentRssWriterProducesValidEmptyFeed()
        {
            var blogInfo = new Blog();
            blogInfo.Host = "localhost";
            blogInfo.Subfolder = "blog";
            blogInfo.Email = "[email protected]";
            blogInfo.RFC3229DeltaEncodingEnabled = true;
            blogInfo.Title = "My Blog Rulz";
            blogInfo.TimeZoneId = TimeZonesTest.PacificTimeZoneId;

            Entry entry = UnitTestHelper.CreateEntryInstanceForSyndication(blogInfo, "haacked", "title of the post",
                                                                           "Body of the post.");
            entry.EntryName = "titleofthepost";
            entry.DateCreatedUtc =
                entry.DatePublishedUtc =
                entry.DateModifiedUtc = DateTime.ParseExact("2006/04/01", "yyyy/MM/dd", CultureInfo.InvariantCulture);

            var context = new Mock<ISubtextContext>();
            context.FakeSyndicationContext(blogInfo, "/", null);
            Mock<BlogUrlHelper> urlHelper = Mock.Get(context.Object.UrlHelper);
            urlHelper.Setup(url => url.EntryUrl(It.IsAny<Entry>())).Returns(
                "/blog/archive/2006/04/01/titleofthepost.aspx");

            var writer = new CommentRssWriter(new StringWriter(), new List<FeedbackItem>(), entry, context.Object);

            Assert.IsTrue(entry.HasEntryName, "This entry should have an entry name.");

            string expected = @"<rss version=""2.0"" "
                              + @"xmlns:dc=""http://purl.org/dc/elements/1.1/"" "
                              + @"xmlns:trackback=""http://madskills.com/public/xml/rss/module/trackback/"" "
                              + @"xmlns:wfw=""http://wellformedweb.org/CommentAPI/"" "
                              + @"xmlns:slash=""http://purl.org/rss/1.0/modules/slash/"" "
                              + @"xmlns:copyright=""http://blogs.law.harvard.edu/tech/rss"" "
                              + @"xmlns:image=""http://purl.org/rss/1.0/modules/image/"">" + Environment.NewLine
                              + indent() + @"<channel>" + Environment.NewLine
                              + indent(2) + @"<title>title of the post</title>" + Environment.NewLine
                              + indent(2) + @"<link>http://localhost/blog/archive/2006/04/01/titleofthepost.aspx</link>" +
                              Environment.NewLine
                              + indent(2) + @"<description>Body of the post.</description>" + Environment.NewLine
                              + indent(2) + @"<language>en-US</language>" + Environment.NewLine
                              + indent(2) + @"<copyright>Subtext Weblog</copyright>" + Environment.NewLine
                              + indent(2) + @"<generator>{0}</generator>" + Environment.NewLine
                              + indent(2) + @"<image>" + Environment.NewLine
                              + indent(3) + @"<title>title of the post</title>" + Environment.NewLine
                              + indent(3) + @"<url>http://localhost/images/RSS2Image.gif</url>" + Environment.NewLine
                              + indent(3) + @"<link>http://localhost/blog/archive/2006/04/01/titleofthepost.aspx</link>" +
                              Environment.NewLine
                              + indent(3) + @"<width>77</width>" + Environment.NewLine
                              + indent(3) + @"<height>60</height>" + Environment.NewLine
                              + indent(2) + @"</image>" + Environment.NewLine
                              + indent(1) + @"</channel>" + Environment.NewLine
                              + @"</rss>";

            expected = string.Format(expected, VersionInfo.VersionDisplayText);

            Assert.AreEqual(expected, writer.Xml);
        }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:57,代码来源:CommentRssWriterTests.cs

示例10: SetHeight

 public void SetHeight()
 {
     Unit test = 100;
     var blog = new Blog {Host = "localhost", Subfolder = "subfolder"};
     var subtextContext = new Mock<ISubtextContext>();
     subtextContext.Setup(c => c.Blog).Returns(blog);
     frtep.InitializeControl(subtextContext.Object);
     frtep.Height = test;
     Assert.AreEqual(test, frtep.Height);
 }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:10,代码来源:FCKeditorProviderTests.cs

示例11: SetText

 public void SetText()
 {
     var blog = new Blog {Host = "localhost", Subfolder = "subfolder"};
     string test = "Lorem Ipsum";
     var subtextContext = new Mock<ISubtextContext>();
     subtextContext.Setup(c => c.Blog).Returns(blog);
     frtep.InitializeControl(subtextContext.Object);
     frtep.Text = test;
     Assert.AreEqual(test, frtep.Text);
     Assert.AreEqual(test, frtep.Xhtml);
 }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:11,代码来源:FCKeditorProviderTests.cs

示例12: SubtextContext

 public SubtextContext(Blog blog, RequestContext requestContext, BlogUrlHelper urlHelper, ObjectRepository repository,
                       IPrincipal user, ICache cache, IDependencyResolver serviceLocator)
 {
     Blog = blog;
     RequestContext = requestContext;
     UrlHelper = urlHelper;
     Repository = repository;
     User = user ?? requestContext.HttpContext.User;
     Cache = cache ?? new SubtextCache(requestContext.HttpContext.Cache);
     ServiceLocator = serviceLocator;
 }
开发者ID:rsaladrigas,项目名称:Subtext,代码行数:11,代码来源:SubtextContext.cs

示例13: CanGetLanguageAndLanguageCode

        public void CanGetLanguageAndLanguageCode()
        {
            var blog = new Blog();
            blog.Language = null;
            Assert.AreEqual("en-US", blog.Language, "By default, the language is en-US");
            Assert.AreEqual("en", blog.LanguageCode);

            blog.Language = "fr-FR";
            Assert.AreEqual("fr-FR", blog.Language, "The language should have changed.");
            Assert.AreEqual("fr", blog.LanguageCode);
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:11,代码来源:BlogInfoTests.cs

示例14: CanTestForEquality

        public void CanTestForEquality()
        {
            var blog = new Blog();
            blog.Id = 12;
            Assert.IsFalse(blog.Equals(null), "Blog should not equal null");
            Assert.IsFalse(blog.Equals("Something Not A Blog"), "Blog should not equal a string");

            var blog2 = new Blog();
            blog2.Id = 12;
            Assert.IsTrue(blog.Equals(blog2));
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:11,代码来源:BlogInfoTests.cs

示例15: CanGetMetaTagsForBlog

        public void CanGetMetaTagsForBlog()
        {
            blog = UnitTestHelper.CreateBlogAndSetupContext();

            InsertNewMetaTag("Adding description meta tag", "description", null, DateTime.Now, blog.Id, null);
            InsertNewMetaTag("no-cache", null, "cache-control", DateTime.Now, blog.Id, null);

            ICollection<MetaTag> tags = MetaTags.GetMetaTagsForBlog(blog, 0, 100);

            Assert.AreEqual(2, tags.Count, "Should be two tags for this blog.");
        }
开发者ID:ChrisPelatari,项目名称:SubText,代码行数:11,代码来源:MetaTagGetTests.cs


注:本文中的Subtext.Framework.Blog类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。