< Summary

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

Metrics

MethodBranch coverage Cyclomatic complexity Line coverage
get_SimulationVoteSlotId()100%10%
get_SimulationUserId()100%10%
get_DisplayName()100%10%
get_RoleName()100%10%
get_Choice()100%10%
get_VoteTime()100%10%

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    {
 11        public string VotingId { get; set; }
 12
 13        public string Name { get; set; }
 14
 15        public string Description { get; set; }
 16
 17        public bool AllowAbstention { get; set; }
 18
 19        public List<SimulationVoteSlotDto> Slots { get; set; } = new List<SimulationVoteSlotDto>();
 20
 21        public int TotalValidVotes => Slots.Count(n => n.Choice == EVoteStates.Pro || n.Choice == EVoteStates.Con);
 22
 23        public int TotalGivenVotes => Slots.Count(n => n.Choice != EVoteStates.NotVoted);
 24
 25        public int ProVotes => Slots.Count(n => n.Choice == EVoteStates.Pro);
 26
 27        public int ConVotes => Slots.Count(n => n.Choice == EVoteStates.Con);
 28
 29        public int AbstentionVotes => Slots.Count(n => n.Choice == EVoteStates.Abstention);
 30
 31        public double ProPercentageOverall
 32        {
 33            get
 34            {
 35                if (Slots == null || Slots.Count == 0)
 36                    return 0;
 37                return Math.Round(ProVotes / (double)Slots.Count * 100, 2);
 38            }
 39        }
 40
 41        public double ConPercentageOverall
 42        {
 43            get
 44            {
 45                if (Slots == null || Slots.Count == 0)
 46                    return 0;
 47                return Math.Round(ConVotes / (double)Slots.Count * 100, 2);
 48            }
 49        }
 50
 51        public double AbstentionPercentageOverall
 52        {
 53            get
 54            {
 55                if (Slots == null || Slots.Count == 0)
 56                    return 0;
 57                return Math.Round(AbstentionVotes / (double)Slots.Count * 100, 2);
 58            }
 59        }
 60
 61        public double ProPercentage
 62        {
 63            get
 64            {
 65                if (this.TotalValidVotes == 0) return 0;
 66                return Math.Round(this.ProVotes / (double)this.TotalValidVotes * 100, 2);
 67            }
 68        }
 69
 70        public double ConPercentage
 71        {
 72            get
 73            {
 74                if (this.TotalValidVotes == 0) return 0;
 75                return Math.Round(this.ConVotes / (double)this.TotalValidVotes * 100, 2);
 76            }
 77        }
 78    }
 79
 80    public class SimulationVoteSlotDto
 81    {
 082        public int SimulationVoteSlotId { get; set; }
 83
 084        public int SimulationUserId { get; set; }
 85
 086        public string DisplayName { get; set; }
 87
 088        public string RoleName { get; set; }
 89
 090        public EVoteStates Choice { get; set; }
 91
 092        public DateTime? VoteTime { get; set; }
 93    }
 94}