Example #1
0
        public void SpeakerViewModelCtor_SortedByOrdinal()
        {
            var tournament = Factory.CreateStartedTournament(6, 1, 3);
            var round      = tournament.GetRoundsOrdered().ToList()[0];
            var entry1     = round.ContestantEntries.FirstOrDefault(p => p.Contestant.Name == "C1");
            var entry2     = round.ContestantEntries.FirstOrDefault(p => p.Contestant.Name == "C2");

            entry1.Ordinal = 2;
            entry2.Ordinal = 1;
            var target = new SpeakerViewModel(tournament);
            var upperMostContestant = target.Heats[0].Contestants[0];

            Assert.AreEqual("C2", upperMostContestant.Name);

            ServiceFaker.ResetIocContainer();
        }
Example #2
0
 public void Cleanup()
 {
     ServiceFaker.ResetIocContainer();
 }
        public void IT_PostRunJudgingsFromWeb_FinalizingJudgementOfOneContestant()
        {
            long?id = null;

            try
            {
                var scores        = new ContestantRunViewModel();
                var wrappedScores = new JudgeViewModel();
                // Setup/Act
                using (var db = new NordicArenaDataContext())
                {
                    var tourney = Factory.CreateInitializedTourney();
                    tourney.Contestants.Add(new Contestant("Roger"));
                    tourney.Contestants.Add(new Contestant("Hans"));
                    var judge = new Judge("Dommer");
                    judge.Tournament = tourney;
                    db.Judges.Add(judge);
                    db.Tournaments.Add(tourney);
                    db.SaveChanges();

                    tourney = db.Tournaments.FirstOrDefault(p => p.Id == tourney.Id);
                    tourney.Start();
                    db.SaveChanges();
                    id = tourney.Id;

                    var round1 = tourney.Rounds.FirstOrDefault();
                    round1.RunsPerContestant = 1;
                    var rc1      = round1.ContestantEntries.FirstOrDefault();
                    var critList = tourney.JudgingCriteria.ToList();
                    // Set up scores
                    scores.RoundContestantId = rc1.Id;
                    scores.TournamentId      = tourney.Id;
                    for (int i = 0; i < critList.Count; i++)
                    {
                        var score = new RunJudging();
                        score.CriterionId       = critList[i].Id;
                        score.JudgeId           = judge.Id;
                        score.RoundContestantId = rc1.Id;
                        score.RunNo             = 1;
                        score.Score             = (i + 1);
                        scores.Scores.Add(score);
                    }

                    wrappedScores.Contestants = new List <ContestantRunViewModel>();
                    wrappedScores.Contestants.Add(scores);
                    wrappedScores.Tournament = tourney;
                }
                // Act
                var ctrl = new TournamentJudgeController(null, new EfTournamentService(), ServiceFaker.GetFakeSignalRHub());

                ctrl.JudgeIndex(wrappedScores);
                // Assert
                using (var db = new EfTournamentService())
                {
                    var rc = db.GetRoundContestantGuarded(scores.RoundContestantId);
                    Assert.IsTrue(rc.TotalScore.HasValue);
                }
            }
            catch (DbEntityValidationException exc)
            {
                throw DbValidationExceptionWrapper.Wrap(exc);
            }
            finally
            {
                DatabaseHelper.DeleteTournament(id);
                ServiceFaker.ResetIocContainer();
            }
        }
 public virtual void CleanUp()
 {
     ServiceFaker.ResetIocContainer();
 }