public void GetScoreFromJudge_Run2_CorrectValue()
        {
            var cont = new RoundContestant();

            cont.EnsureListsAreInitialized();
            cont.RunJudgings.Add(new RunJudging()
            {
                Score = 5, RunNo = 1, JudgeId = 1
            });
            cont.RunJudgings.Add(new RunJudging()
            {
                Score = null, RunNo = 1, JudgeId = 1
            });
            cont.RunJudgings.Add(new RunJudging()
            {
                Score = 10, RunNo = 1, JudgeId = 1
            });
            cont.RunJudgings.Add(new RunJudging()
            {
                Score = 8, RunNo = 1, JudgeId = 2
            });
            cont.RunJudgings.Add(new RunJudging()
            {
                Score = 10, RunNo = 2, JudgeId = 1
            });
            var res = cont.GetScoreFromJudgeRun(judgeId: 1L, runNo: 2);

            Assert.AreEqual(10M, res);
        }
        public void GetScoreFromJudge_NoData_Null()
        {
            var cont = new RoundContestant();

            cont.EnsureListsAreInitialized();
            var res = cont.GetScoreFromJudgeRun(0, 0);

            Assert.IsNull(res);
        }
        public RunJudgementViewModel(List <RunJudging> runJudgings, NordicArenaDomainModels.Models.Judge judge = null, RoundContestant roundContestant = null, int?runNo = null)
            : this()
        {
            if ((roundContestant == null || runNo == null || judge == null) && (runJudgings == null || runJudgings.Count == 0))
            {
                throw new ArgumentException("No entries in list or list null, while not supplied judge, roundContestant and runNo explicitly");
            }
            if (roundContestant == null)
            {
                roundContestant = runJudgings[0].RoundContestant;
            }
            if (runNo == null)
            {
                runNo = runJudgings[0].RunNo;
            }
            if (judge == null)
            {
                judge = runJudgings[0].Judge;
            }

            ContestantName    = roundContestant.Contestant != null ? roundContestant.Contestant.Name : "(not set)";
            RunNo             = runNo.Value;
            JudgeName         = judge.Name;
            RoundContestantId = roundContestant.Id;
            JudgeId           = judge.Id;
            RunJudgeScore     = roundContestant.GetScoreFromJudgeRun(judge.Id, runNo.Value);
            foreach (var rj in runJudgings)
            {
                if (rj.RunNo != runNo)
                {
                    throw new ArgumentException(String.Format("Expected all runJudgements to be from run {0}, but one is from run {1}", runNo, rj.RunNo));
                }
                if (rj.RoundContestantId != roundContestant.Id)
                {
                    throw new ArgumentException(String.Format("Expected all runJudgements to be from roundContestantId {0}, but one is from {1}", roundContestant.Id, rj.RoundContestantId));
                }
                if (rj.JudgeId != judge.Id)
                {
                    throw new ArgumentException(String.Format("Expected all runJudgements to be from judgeId {0}, but one is from {1}", judge.Id, rj.JudgeId));
                }
                Scores.Add(rj.Score);
            }
        }