public async Task PerformGetPostTest(bool requestFreePost) { var expectedResult = new GetPostQueryResult( new GetPostQueryResult.FullPost( UserId, new GetPreviewNewsfeedQueryResult.PreviewPostCreator(new Username(UserId.ToString()), null), PostId, BlogId, new GetPreviewNewsfeedQueryResult.PreviewPostBlog(new BlogName(BlogId.ToString()), null, null), ChannelId, new GetPreviewNewsfeedQueryResult.PreviewPostChannel(new ChannelName(ChannelId.ToString())), new Comment(string.Empty), 0, 0, 0, 0, 0, DateTime.UtcNow, 0, 0, false, true, true), new List <GetPostQueryResult.File>()); var timestamp = DateTime.UtcNow; this.timestampCreator.Setup(v => v.Now()).Returns(timestamp); this.requesterContext.Setup(_ => _.GetRequesterAsync()).ReturnsAsync(Requester); this.getPost.Setup(v => v.HandleAsync(new GetPostQuery(Requester, PostId, requestFreePost, timestamp))) .Returns(Task.FromResult(expectedResult)) .Verifiable(); var result = await this.target.GetPost(PostId.Value.EncodeGuid(), requestFreePost); Assert.AreEqual(expectedResult, result); this.getPost.Verify(); }
public void ProcessRequest(HttpContext context) { _site = null; if (SiteId != 0) { _site = new AWAPI_BusinessLibrary.library.SiteLibrary().Get(SiteId); } if (_site == null || !_site.isEnabled) { return; } string link = String.IsNullOrEmpty(_site.link) ? "http://awapi.com" : _site.link; _feed = new SyndicationFeed(_site.title + " - Blog Feed", "", new Uri(link)); _feed.Authors.Add(new SyndicationPerson("*****@*****.**")); _feed.AttributeExtensions.Add(new XmlQualifiedName("site"), _site.title); _feed.AttributeExtensions.Add(new XmlQualifiedName("sitelink"), _site.link); _feed.AttributeExtensions.Add(new XmlQualifiedName("defaultculture"), _site.cultureCode); _feed.AttributeExtensions.Add(new XmlQualifiedName("currentpostid"), CurrentPostId.ToString()); _feed.AttributeExtensions.Add(new XmlQualifiedName("servertime"), DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss")); if (BlogId > 0) { _feed.AttributeExtensions.Add(new XmlQualifiedName("blogid"), BlogId.ToString()); } if (BlogCategoryId > 0) { _feed.AttributeExtensions.Add(new XmlQualifiedName("blogcategoryid"), BlogCategoryId.ToString()); } if (PostId > 0) { _feed.AttributeExtensions.Add(new XmlQualifiedName("postid"), PostId.ToString()); } AddParamsToFeed(); context.Response.ContentType = "text/xml"; context.Response.ContentEncoding = System.Text.Encoding.UTF8; switch (MethodName) { case "getblog": _feed.Title = new TextSyndicationContent(_site.title + " - Blog"); _feed.Categories.Add(new SyndicationCategory("blogs")); GetBlog(SiteId, BlogId); break; case "getbloglist": _feed.Title = new TextSyndicationContent(_site.title + " - Blog List"); _feed.Categories.Add(new SyndicationCategory("blogs")); GetBlogList(SiteId); break; case "getcategorylist": _feed.Title = new TextSyndicationContent(_site.title + " - Blog Category List"); _feed.Categories.Add(new SyndicationCategory("blogs")); GetCategoryList(BlogId); break; case "getpost": _feed.Title = new TextSyndicationContent(_site.title + " - Blog Post"); _feed.Categories.Add(new SyndicationCategory("posts")); GetBlogPost(SiteId, PostId); break; case "getpostfilelist": _feed.Title = new TextSyndicationContent(_site.title + " - Blog Post File List"); _feed.Categories.Add(new SyndicationCategory("files")); GetBlogPostFileList(SiteId, PostId); break; case "getpostlist": _feed.Title = new TextSyndicationContent(_site.title + " - Post List"); _feed.Categories.Add(new SyndicationCategory("posts")); GetBlogPostList(SiteId, BlogId, BlogCategoryId, TagId, Search, PageIndex, PageSize); break; case "getarchivedpostlist": _feed.Title = new TextSyndicationContent(_site.title + " - Archived Post List"); _feed.Categories.Add(new SyndicationCategory("posts")); GetArchivedBlogPostList(SiteId, BlogId, Archive, PageIndex, PageSize); break; case "getarchivelist": _feed.Title = new TextSyndicationContent(_site.title + " - Post Archive List"); _feed.Categories.Add(new SyndicationCategory("posts")); GetBlogPostArchiveList(BlogId); break; case "getcommentlist": _feed.Title = new TextSyndicationContent(_site.title + " - Comment List"); _feed.Categories.Add(new SyndicationCategory("comments")); GetBlogCommentList(SiteId, BlogId, PostId); break; case "gettaglist": _feed.Title = new TextSyndicationContent(_site.title + " - Tag List"); _feed.Categories.Add(new SyndicationCategory("tags")); GetBlogTagList(BlogId, PostId); break; default: break; } WriteFeed(); }
public DecoratedBlog(Blog blog, IDataProtector protector) : base(blog) { ProtectedID = protector.Protect(BlogId.ToString()); }
private static void AssertExpectedResult(bool hasLiked, bool isFreePost, GetPostDbResult result) { Assert.AreEqual( new PreviewNewsfeedPost( CreatorId, CreatorUsername, null, null, Introduction, PostId, BlogId, BlogId.ToString(), ChannelId, ChannelId.ToString(), PreviewText, Content, FileId1, PreviewWordCount, WordCount, ImageCount, FileCount, VideoCount, LiveDate, FileName1, FileExtension1, FileSize1, FileWidth1, FileHeight1, 1 + (hasLiked ? 1 : 0), 1, hasLiked, isFreePost, CreationDate), result.Post); Assert.AreEqual(2, result.Files.Count); var file1 = result.Files.Single(v => v.FileId.Equals(FileId1)); var file2 = result.Files.Single(v => v.FileId.Equals(FileId2)); Assert.AreEqual( new GetPostDbResult.PostFileDbResult( FileId1, FileName1, FileExtension1, FilePurpose1, FileSize1, FileWidth1, FileHeight1), file1); Assert.AreEqual( new GetPostDbResult.PostFileDbResult( FileId2, FileName2, FileExtension2, FilePurpose2, FileSize2, FileWidth2, FileHeight2), file2); }