/// <summary>Initializes a new instance of the <see cref="KnowledgeArticle"/> class. Knowledge Article initialization</summary> /// <param name="article">Knowledge Article record entity</param> /// <param name="commentCount">The comment Count.</param> /// <param name="commentPolicy">The comment Policy.</param> /// <param name="isRatingEnabled">The is Rating Enabled.</param> /// <param name="httpContext">The http Context.</param> public KnowledgeArticle( Entity article, int commentCount, CommentPolicy commentPolicy, bool isRatingEnabled, HttpContextBase httpContext) { article.ThrowOnNull("article"); article.AssertEntityName("knowledgearticle"); this.httpContext = httpContext; this.Entity = article; this.EntityReference = article.ToEntityReference(); this.Id = article.Id; this.Title = article.GetAttributeValue <string>("title"); this.ArticlePublicNumber = article.GetAttributeValue <string>("articlepublicnumber"); this.RootArticle = article.GetAttributeValue <EntityReference>("rootarticleid"); this.Content = article.GetAttributeValue <string>("content"); this.Keywords = article.GetAttributeValue <string>("keywords"); this.CommentCount = commentCount; this.IsRatingEnabled = isRatingEnabled; this.CommentPolicy = commentPolicy; this.CurrentUserCanComment = commentPolicy == CommentPolicy.Open || commentPolicy == CommentPolicy.Moderated || (commentPolicy == CommentPolicy.OpenToAuthenticatedUsers && httpContext.Request.IsAuthenticated); this.url = new Lazy <string>(this.GetUrl, LazyThreadSafetyMode.None); this.articleViews = new Lazy <int>(this.GetArticleViews); this.articleRating = new Lazy <decimal>(this.GetArticleRating); }
public void CreatesCorrectPolicy(string comment) { var basePolicy = new CommentPolicy(comment); var xml = basePolicy.GetXml().ToString(); xml.Should().Be($"<!-- {comment} -->"); }