< Summary

Class:MUNity.Schema.Simulation.Voting.SimulationVotingDto
Assembly:MUNity.Schema
File(s):C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNitySchema\Schema\Simulation\Voting\SimulationVotingDto.cs
Covered lines:0
Uncovered lines:33
Coverable lines:33
Total lines:94
Line coverage:0% (0 of 33)
Covered branches:0
Total branches:18
Branch coverage:0% (0 of 18)
Covered methods:0
Total methods:15
Method coverage:0% (0 of 15)

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_VotingId()100%10%
get_Name()100%10%
get_Description()100%10%
get_AllowAbstention()100%10%
get_Slots()100%10%
get_TotalValidVotes()0%20%
get_TotalGivenVotes()100%10%
get_ProVotes()100%10%
get_ConVotes()100%10%
get_AbstentionVotes()100%10%
get_ProPercentageOverall()0%40%
get_ConPercentageOverall()0%40%
get_AbstentionPercentageOverall()0%40%
get_ProPercentage()0%20%
get_ConPercentage()0%20%

File(s)

C:\Users\aeuke\source\repos\PeerConradi\munity\src\MUNitySchema\Schema\Simulation\Voting\SimulationVotingDto.cs

#LineLine coverage
 1using MUNity.Base;
 2using System;
 3using System.Collections.Generic;
 4using System.Linq;
 5using System.Text;
 6
 7namespace MUNity.Schema.Simulation.Voting
 8{
 9    public class SimulationVotingDto
 10    {
 011        public string VotingId { get; set; }
 12
 013        public string Name { get; set; }
 14
 015        public string Description { get; set; }
 16
 017        public bool AllowAbstention { get; set; }
 18
 019        public List<SimulationVoteSlotDto> Slots { get; set; } = new List<SimulationVoteSlotDto>();
 20
 021        public int TotalValidVotes => Slots.Count(n => n.Choice == EVoteStates.Pro || n.Choice == EVoteStates.Con);
 22
 023        public int TotalGivenVotes => Slots.Count(n => n.Choice != EVoteStates.NotVoted);
 24
 025        public int ProVotes => Slots.Count(n => n.Choice == EVoteStates.Pro);
 26
 027        public int ConVotes => Slots.Count(n => n.Choice == EVoteStates.Con);
 28
 029        public int AbstentionVotes => Slots.Count(n => n.Choice == EVoteStates.Abstention);
 30
 31        public double ProPercentageOverall
 32        {
 33            get
 034            {
 035                if (Slots == null || Slots.Count == 0)
 036                    return 0;
 037                return Math.Round(ProVotes / (double)Slots.Count * 100, 2);
 038            }
 39        }
 40
 41        public double ConPercentageOverall
 42        {
 43            get
 044            {
 045                if (Slots == null || Slots.Count == 0)
 046                    return 0;
 047                return Math.Round(ConVotes / (double)Slots.Count * 100, 2);
 048            }
 49        }
 50
 51        public double AbstentionPercentageOverall
 52        {
 53            get
 054            {
 055                if (Slots == null || Slots.Count == 0)
 056                    return 0;
 057                return Math.Round(AbstentionVotes / (double)Slots.Count * 100, 2);
 058            }
 59        }
 60
 61        public double ProPercentage
 62        {
 63            get
 064            {
 065                if (this.TotalValidVotes == 0) return 0;
 066                return Math.Round(this.ProVotes / (double)this.TotalValidVotes * 100, 2);
 067            }
 68        }
 69
 70        public double ConPercentage
 71        {
 72            get
 073            {
 074                if (this.TotalValidVotes == 0) return 0;
 075                return Math.Round(this.ConVotes / (double)this.TotalValidVotes * 100, 2);
 076            }
 77        }
 78    }
 79
 80    public class SimulationVoteSlotDto
 81    {
 82        public int SimulationVoteSlotId { get; set; }
 83
 84        public int SimulationUserId { get; set; }
 85
 86        public string DisplayName { get; set; }
 87
 88        public string RoleName { get; set; }
 89
 90        public EVoteStates Choice { get; set; }
 91
 92        public DateTime? VoteTime { get; set; }
 93    }
 94}