< Summary

Information
Class: MRA.Services.Models.Drawings.DrawingVoteManager
Assembly: MRA.Services
File(s): D:\a\MiguelRomerART\MiguelRomerART\MRA.Services\Models\Drawings\DrawingVoteManager.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 33
Line coverage: 100%
Branch coverage
100%
Covered branches: 6
Total branches: 6
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
UpdateDrawingScore(...)100%22100%
CalculateUserScore(...)100%11100%
AdjustUserScore(...)100%44100%

File(s)

D:\a\MiguelRomerART\MiguelRomerART\MRA.Services\Models\Drawings\DrawingVoteManager.cs

#LineLine coverage
 1using MRA.DTO.Models;
 2
 3namespace MRA.Services.Models.Drawings;
 4
 5public static class DrawingVoteManager
 6{
 7    public static void UpdateDrawingScore(this DrawingModel drawing, int newScore)
 8    {
 49        newScore = newScore.AdjustUserScore();
 410        if (drawing.VotesPopular > 0)
 11        {
 212            drawing.ScorePopular = CalculateUserScore(newScore, drawing.ScorePopular, drawing.VotesPopular);
 213            drawing.VotesPopular = drawing.VotesPopular + 1;
 14        }
 15        else
 16        {
 217            drawing.ScorePopular = newScore;
 218            drawing.VotesPopular = 1;
 19        }
 220    }
 21
 22    public static double CalculateUserScore(int newScore, double scorePopular, int currentVotes)
 23    {
 324        return ((scorePopular * currentVotes) + newScore.AdjustUserScore()) / (currentVotes + 1);
 25    }
 26
 27    private static int AdjustUserScore(this int score)
 28    {
 829        if (score > 100) score = 100;
 830        if (score < 0) score = 0;
 731        return score;
 32    }
 33}