< Summary

Class:ApplicationCore.Model.CommentFactory
Assembly:ApplicationCore
File(s):C:\Users\Teknikaali\Source\Repos\jekyll-blog-comments\ApplicationCore\Model\CommentFactory.cs
Covered lines:14
Uncovered lines:0
Coverable lines:14
Total lines:31
Line coverage:100% (14 of 14)
Covered branches:2
Total branches:2
Branch coverage:100% (2 of 2)

Coverage History

Metrics

MethodCyclomatic complexity NPath complexity Sequence coverage Branch coverage
.ctor(...)10100%100%
CreateFromFormAsync()20100%100%

File(s)

C:\Users\Teknikaali\Source\Repos\jekyll-blog-comments\ApplicationCore\Model\CommentFactory.cs

#LineLine coverage
 1using System.Threading.Tasks;
 2using ApplicationCore.Analytics;
 3using Microsoft.AspNetCore.Http;
 4
 5namespace ApplicationCore.Model
 6{
 7    public class CommentFactory : ICommentFactory
 8    {
 9        private readonly ICommentFormFactory _commentFormFactory;
 10        private readonly ITextAnalyzer _textAnalyzer;
 11
 412        public CommentFactory(ICommentFormFactory commentFormFactory, ITextAnalyzer textAnalyzer)
 413        {
 414            _commentFormFactory = commentFormFactory;
 415            _textAnalyzer = textAnalyzer;
 416        }
 17
 18        public async Task<CommentResult> CreateFromFormAsync(IFormCollection form)
 219        {
 220            var commentForm = _commentFormFactory.CreateCommentForm(form);
 221            var commentResult = commentForm.TryCreateComment();
 22
 223            if (!commentForm.HasErrors)
 124            {
 125                commentResult = await _textAnalyzer.AnalyzeAsync(commentResult.Comment).ConfigureAwait(false);
 126            }
 27
 228            return commentResult;
 229        }
 30    }
 31}