public void GetGradeAverage_ShouldYieldArithmeticAverage_WhenThereIsOneNeutralGrade()
        {
            var article = new Article();
            AddGrades(article, 3);

            decimal grade = article.GetGradeAverage();

            Assert.That(grade, Is.EqualTo(3m));
        }
        public void GetGradeAverage_ShouldYieldArithmeticAverage_WhenThereAreManyGrades()
        {
            var article = new Article();
            AddGrades(article, 2, 5, 2, 3, 2, 1, 4, 5);

            decimal grade = article.GetGradeAverage();

            Assert.That(grade, Is.EqualTo(3m));
        }
        public void GetGradeAverage_ShouldYieldArithmeticAverageWithDecimals()
        {
            var article = new Article();
            AddGrades(article, 2);

            decimal grade = article.GetGradeAverage();

            Assert.That(grade, Is.EqualTo(2.5m));
        }
        public void GetGradeAverage_ShouldYieldArithmeticAverageRoundedDownToTwoDecimals_WhenThereAreManyGrades()
        {
            var article = new Article();
            AddGrades(article, 4, 1);

            decimal grade = article.GetGradeAverage();

            Assert.That(grade, Is.EqualTo(2.66m));
        }
 public ArticleDetailsModel(Article article, string currentUserName)
 {
     Title = article.Title;
     AuthorUserName = article.Author.UserName;
     GradeAverage = Format.Grade(article.GetGradeAverage());
     Summary = article.Summary;
     Body = article.Body;
     EmailAddress = article.EmailAddress;
     var userGrade = article.Grades.SingleOrDefault(g => g.User.UserName == currentUserName);
     GradeValue = (userGrade == null ? null : (int?)userGrade.GradeValue);
 }
 public void GetGradeAverage_ShouldYield3_WhenThereAreNoGrades()
 {
     var article = new Article();
     decimal grade = article.GetGradeAverage();
     Assert.That(grade, Is.EqualTo(3m));
 }