Beispiel #1
0
        public void ToFullyQualifiedUrl_WithNullVirtualPath_ReturnsNull()
        {
            VirtualPath vp = null;

            Assert.IsNull(vp.ToFullyQualifiedUrl(new Blog()));
            Assert.IsNull(vp.ToFullyQualifiedUrl(null));
        }
Beispiel #2
0
        public void VirtualPath_WithFragment_SetsFragmentPropertyWithFragment()
        {
            //arrange
            var vp = new VirtualPath("/foo#bar");

            //assert
            Assert.AreEqual("/foo#bar", vp.ToString());
            Assert.AreEqual("#bar", vp.ToFullyQualifiedUrl(new Blog {
                Host = "localhost"
            }).Fragment);
        }
Beispiel #3
0
        public void ToFullyQualifiedUrl_WithBlog_ReturnsUri()
        {
            //arrange
            VirtualPath vp = "/foo";

            //act
            Uri fullyQualified = vp.ToFullyQualifiedUrl(new Blog {
                Host = "localhost"
            });

            //assert
            Assert.AreEqual("http://localhost/foo", fullyQualified.ToString());
        }
Beispiel #4
0
        public void ToFullyQualifiedUrl_WithQueryString_ReturnsUriWithQueryString()
        {
            var x = new Uri("/foo", UriKind.Relative);

            Console.WriteLine(x.ToString());
            //arrange
            VirtualPath vp = "/foo?a=b";

            //act
            Uri uri = vp.ToFullyQualifiedUrl(new Blog {
                Host = "localhost"
            });

            //assert
            Assert.AreEqual("?a=b", uri.Query);
        }
Beispiel #5
0
        public void ToFullyQualifiedUrl_WithBlogAndPort_ReturnsUriWithPort()
        {
            //arrange
            try
            {
                VirtualPath vp = "/foo";
                UnitTestHelper.SetHttpContextWithBlogRequest("localhost", 8080, "", "");

                //act
                Uri fullyQualified = vp.ToFullyQualifiedUrl(new Blog {
                    Host = "localhost"
                });

                //assert
                Assert.AreEqual("http://localhost:8080/foo", fullyQualified.ToString());
            }
            finally
            {
                HttpContext.Current = null;
            }
        }
Beispiel #6
0
        public void ToFullyQualifiedUrl_WithNullBlog_ThrowsArgumentNullException()
        {
            VirtualPath vp = "/";

            UnitTestHelper.AssertThrowsArgumentNullException(() => vp.ToFullyQualifiedUrl(null));
        }
        /// <summary>
        /// Returns the image that will be displayed in an RSS aggregator that supports RSS images.
        /// </summary>
        /// <returns></returns>
        public virtual Uri GetRssImage()
        {
            VirtualPath url = UrlHelper.ImageUrl("RSS2Image.gif");

            return(url.ToFullyQualifiedUrl(Blog));
        }
Beispiel #8
0
        private void BindPostEdit()
        {
            Debug.Assert(PostId != null, "PostId Should not be null when we call this");

            SetConfirmation();

            Entry entry = GetEntryForEditing(PostId.Value);

            if (entry == null)
            {
                ReturnToOrigin(null);
                return;
            }

            txbTitle.Text = entry.Title;
            if (!entry.DatePublishedUtc.IsNull() && entry.DatePublishedUtc > DateTime.UtcNow)
            {
                txtPostDate.Text = entry.DateSyndicated.ToString(CultureInfo.CurrentCulture);
            }

            VirtualPath entryUrl = Url.EntryUrl(entry);

            if (entryUrl != null)
            {
                hlEntryLink.NavigateUrl = entryUrl;
                hlEntryLink.Text        = entryUrl.ToFullyQualifiedUrl(Config.CurrentBlog).ToString();
                hlEntryLink.Attributes.Add("title", "view: " + entry.Title);
            }
            else
            {
                hlEntryLink.Text = "This post has not been published yet, so it doesn't have an URL";
            }

            PopulateMimeTypeDropDown();
            //Enclosures
            if (entry.Enclosure != null)
            {
                Enclosure.Collapsed    = false;
                txbEnclosureTitle.Text = entry.Enclosure.Title;
                txbEnclosureUrl.Text   = entry.Enclosure.Url;
                txbEnclosureSize.Text  = entry.Enclosure.Size.ToString();
                if (ddlMimeType.Items.FindByText(entry.Enclosure.MimeType) != null)
                {
                    ddlMimeType.SelectedValue = entry.Enclosure.MimeType;
                }
                else
                {
                    ddlMimeType.SelectedValue      = "other";
                    txbEnclosureOtherMimetype.Text = entry.Enclosure.MimeType;
                }
                ddlAddToFeed.SelectedValue     = entry.Enclosure.AddToFeed.ToString().ToLower();
                ddlDisplayOnPost.SelectedValue = entry.Enclosure.ShowWithPost.ToString().ToLower();
            }

            chkComments.Checked       = entry.AllowComments;
            chkCommentsClosed.Checked = entry.CommentingClosed;
            SetCommentControls();
            if (entry.CommentingClosedByAge)
            {
                chkCommentsClosed.Enabled = false;
            }

            chkDisplayHomePage.Checked          = entry.DisplayOnHomePage;
            chkMainSyndication.Checked          = entry.IncludeInMainSyndication;
            chkSyndicateDescriptionOnly.Checked = entry.SyndicateDescriptionOnly;
            chkIsAggregated.Checked             = entry.IsAggregated;

            // Advanced Options
            txbEntryName.Text = entry.EntryName;
            txbExcerpt.Text   = entry.Description;

            SetEditorText(entry.Body);

            ckbPublished.Checked = entry.IsActive;

            BindCategoryList();
            for (int i = 0; i < cklCategories.Items.Count; i++)
            {
                cklCategories.Items[i].Selected = false;
            }

            ICollection <Link> postCategories = Repository.GetLinkCollectionByPostId(PostId.Value);

            if (postCategories.Count > 0)
            {
                foreach (Link postCategory in postCategories)
                {
                    ListItem categoryItem =
                        cklCategories.Items.FindByValue(postCategory.CategoryId.ToString(CultureInfo.InvariantCulture));
                    if (categoryItem == null)
                    {
                        throw new InvalidOperationException(
                                  string.Format(Resources.EntryEditor_CouldNotFindCategoryInList, postCategory.CategoryId,
                                                cklCategories.Items.Count));
                    }
                    categoryItem.Selected = true;
                }
            }

            SetEditorMode();
            Advanced.Collapsed = !Preferences.AlwaysExpandAdvanced;

            var adminMasterPage = Page.Master as AdminPageTemplate;

            if (adminMasterPage != null)
            {
                string title = string.Format(CultureInfo.InvariantCulture, Resources.EntryEditor_EditingTitle,
                                             CategoryType == CategoryType.StoryCollection
                                                 ? Resources.Label_Article
                                                 : Resources.Label_Post, entry.Title);
                adminMasterPage.Title = title;
            }

            if (entry.HasEntryName)
            {
                Advanced.Collapsed = false;
                txbEntryName.Text  = entry.EntryName;
            }
        }
        public void VirtualPath_WithFragment_SetsFragmentPropertyWithFragment()
        {
            //arrange
            var vp = new VirtualPath("/foo#bar");

            //assert
            Assert.AreEqual("/foo#bar", vp.ToString());
            Assert.AreEqual("#bar", vp.ToFullyQualifiedUrl(new Blog {Host = "localhost"}).Fragment);
        }