示例#1
0
        public void ThumbnailPath()
        {
            string filename = Guid.NewGuid().ToString() + ".jpg";
            string result   = "";

            result = VoatPathHelper.ThumbnailPath(filename);
            if (Settings.UseContentDeliveryNetwork)
            {
                Assert.AreEqual(String.Format("~/thumbs/{0}", filename), result, "Condition:1");
            }
            else
            {
                Assert.AreEqual(String.Format("~/thumbs/{0}", filename), result, "Condition:1");
            }

            result = VoatPathHelper.ThumbnailPath(filename, true);
            if (Settings.UseContentDeliveryNetwork)
            {
                Assert.AreEqual(String.Format("//cdn.voat.co/thumbs/{0}", filename), result, "Condition:2");
            }
            else
            {
                Assert.AreEqual(String.Format("//voat.co/thumbs/{0}", filename), result, "Condition:2");
            }

            result = VoatPathHelper.ThumbnailPath(filename, true, true);
            if (Settings.UseContentDeliveryNetwork)
            {
                Assert.AreEqual(String.Format("https://cdn.voat.co/thumbs/{0}", filename), result, "Condition:3");
            }
            else
            {
                Assert.AreEqual(String.Format("https://voat.co/thumbs/{0}", filename), result, "Condition:3");
            }
        }
示例#2
0
        public static Domain.Models.Submission Map(this Data.Models.Submission submission)
        {
            Domain.Models.Submission result = null;
            if (submission != null)
            {
                result = new Domain.Models.Submission()
                {
                    ID       = submission.ID,
                    UserName = (submission.IsAnonymized ? submission.ID.ToString() : submission.UserName),

                    Title   = submission.Title,
                    Url     = submission.Url,
                    Content = (submission.Type == 1 ? submission.Content : (string)null),

                    //Support For Backwards compat, if FormattedContent is empty, do it here.
                    FormattedContent = (submission.Type == 1 && String.IsNullOrEmpty(submission.FormattedContent) ? Formatting.FormatMessage(submission.Content, true) : submission.FormattedContent),

                    LastEditDate = submission.LastEditDate,
                    ThumbnailUrl = VoatPathHelper.ThumbnailPath(submission.Thumbnail, true, true),
                    CommentCount = CommentCounter.CommentCount(submission.ID),
                    CreationDate = submission.CreationDate,
                    UpCount      = (int)submission.UpCount,
                    Views        = (int)submission.Views,
                    DownCount    = (int)submission.DownCount,
                    Type         = submission.Type == 1 ? SubmissionType.Text : SubmissionType.Link,
                    Subverse     = submission.Subverse,
                    IsAnonymized = submission.IsAnonymized,
                    IsDeleted    = submission.IsDeleted,
                    Rank         = submission.Rank,
                    RelativeRank = submission.RelativeRank
                };
            }
            return(result);
        }