public void WillUpdateScoreForOneOnOne()
        {
            // Arrange
            var ladder         = new Ladder("Default", 2, 1);
            var scoringService = new ScoringService(TestUtils.GetUnitOfWork());

            var game = TestUtils.CreateStartedGameWithMapAndPlayersUnitsPlaced();

            game.Teams.First().Players.First().Surrender();

            game.LadderId = ladder.Id;
            game.Ladder   = ladder;

            // Act
            scoringService.Score(ladder, game);

            // Assert
            //Assert.AreEqual(2, ladder.Standings.Count, "Player standings have not been created");

            //var player1Standing = ladder.Standings.First(x => x.UserId == game.Teams.First().Players.First().User.Id);
            //var player2Standing = ladder.Standings.First(x => x.UserId == game.Teams.Last().Players.First().User.Id);

            //Assert.IsTrue(player1Standing.Rating < player2Standing.Rating);
            //Assert.AreEqual(1, player1Standing.GamesLost);
            //Assert.AreEqual(1, player1Standing.GamesPlayed);
        }
예제 #2
0
        public void ScoreWeek([FromBody] Object weekToScore)
        {
            var         jsonString = weekToScore.ToString();
            WeekToScore result     = JsonConvert.DeserializeObject <WeekToScore>(jsonString);

            ScoringService.ScoreGamesForWeek(result.Week, result.Year);
        }
        public void WillUpdateScoreForOneOnOne()
        {
            // Arrange
            var ladder = new Ladder("Default", 2, 1);
            var scoringService = new ScoringService();

            var game = TestUtils.CreateStartedGameWithMapAndPlayersUnitsPlaced();
            game.Teams.First().Players.First().Surrender();

            game.LadderId = ladder.Id;
            game.Ladder = ladder;

            // Act
            scoringService.Score(ladder, game);

            // Assert
            Assert.AreEqual(2, ladder.Standings.Count, "Player standings have not been created");

            var player1Standing = ladder.Standings.First(x => x.UserId == game.Teams.First().Players.First().User.Id);
            var player2Standing = ladder.Standings.First(x => x.UserId == game.Teams.Last().Players.First().User.Id);

            Assert.IsTrue(player1Standing.Rating < player2Standing.Rating);
            Assert.AreEqual(1, player1Standing.GamesLost);
            Assert.AreEqual(1, player1Standing.GamesPlayed);
        }
예제 #4
0
        public GameViewModel(ScoringService scoringService, GridService gridService)
        {
            _scoringService = scoringService;
            _gridService    = gridService;
            Cells           = new ObservableCollection <GridCell>();

            StartGame.Execute(null);
        }
예제 #5
0
 public ScoringServiceTests()
 {
     _context = InMemoryContextBuilder.GetContext();
     _mapper  = MapperBuilder.GetSailScoresMapper();
     _service = new ScoringService(
         _context,
         _mapper);
 }
예제 #6
0
        public IActionResult Index()
        {
            var options        = _optionsAccessor.Value;
            var scoringService = new ScoringService(options.MazeGameApiUrl, options.DbApiUrl);
            var model          = scoringService.GetAllTeams();

            var timeLeft = scoringService.GetTimeLeft(options.TimerName);

            ViewData["TimeLeft"] = timeLeft;
            return(View(model));
        }
예제 #7
0
        public void ContractScoreIsCorrect(Tuple <string, int> testedContract)
        {
            Contract      contract = new Contract(testedContract.Item1);
            List <Player> players  = new List <Player>();

            players.AddRange(_ps.CreatePlayers(Musketeers()));
            ScoringService scoringService = new ScoringService(players, bettingService);

            var score = scoringService.GetContractScore(contract);

            Assert.That(score, Is.EqualTo(testedContract.Item2));
        }
예제 #8
0
        public void TargetScoreIsCorrectForPlayer(int oudlersQuantity, int expectedScore)
        {
            List <Player> players = new List <Player>();

            players.AddRange(_ps.CreatePlayers(Musketeers()));
            ScoringService scoringService = new ScoringService(players, bettingService);

            players.First().Attacker = true;
            for (int i = 0; i < oudlersQuantity; i++)
            {
                players.First().WonHands.Add(new Card("trumpers", 1));
            }

            var targetScore = scoringService.GetTargetScore(players);

            Assert.That(targetScore, Is.EqualTo(expectedScore));
        }
예제 #9
0
        public void GetScore_CorrectScore_ReturnScore(
            int correctScore,
            int maxScore,
            NumberComparison compare_first,
            NumberComparison compare_second,
            int resultScore)
        {
            _mockConfigurationService.Setup(a => a.GetCorrectScore()).Returns(correctScore);
            _mockConfigurationService.Setup(a => a.GetMaxTotalScore()).Returns(maxScore);

            var serviceUnderTest = new ScoringService(_mockConfigurationService.Object);

            var result = serviceUnderTest.GetScore(compare_first, compare_second);

            Assert.NotNull(result);
            Assert.GreaterOrEqual(resultScore, result);
        }
예제 #10
0
        public ReportForm(Race race)
        {
            InitializeComponent();
            this.race = race;
            string connStr = ConfigurationManager.ConnectionStrings["triathlon"].ToString();
            IDictionary <string, string> props = new SortedList <string, string>();

            props.Add("ConnectionString", connStr);
            ParticipantRepository participantRepository = new ParticipantRepository(props);
            ScoreRepository       scoreRepository       = new ScoreRepository(props);
            ScoringService        scoringService        = new ScoringService(participantRepository, scoreRepository);

            this.scoringService = scoringService;
            DataTable dataTable = scoringService.generateReport(this.race).Tables[0];

            dataGridView1.DataSource = dataTable;
        }
예제 #11
0
        public void CompareScore_ProvideScore_ReturnScoreResponse(
            int score,
            int totalScore,
            bool playAgain,
            bool success,
            int userScore)
        {
            _mockConfigurationService.Setup(a => a.GetCorrectScore()).Returns(1);
            _mockConfigurationService.Setup(a => a.GetMaxTotalScore()).Returns(10);

            var serviceUnderTest = new ScoringService(_mockConfigurationService.Object);
            var result           = serviceUnderTest.CompareScore(score, totalScore);

            Assert.NotNull(result);
            Assert.GreaterOrEqual(playAgain, result.PlayAgain);
            Assert.GreaterOrEqual(success, result.Success);
            Assert.GreaterOrEqual(userScore, result.UserTotalScore);
        }
예제 #12
0
    public IEnumerable <DataAnnotations.ValidationResult> Validate(DataAnnotations.ValidationContext validationContext)
    {
        var discardSequenceErrors = ScoringService.GetDiscardSequenceErrors(this.DiscardPattern);
        var errorString           = new StringBuilder();

        foreach (var error in discardSequenceErrors)
        {
            if (errorString.Length > 0)
            {
                errorString.Append("; ");
            }
            errorString.Append(error);
        }
        if (errorString.Length > 0)
        {
            yield return(new DataAnnotations.ValidationResult(
                             $"Discard pattern is not valid: {errorString}",
                             new[] { nameof(DiscardPattern) }));
        }
    }
예제 #13
0
        private static void TestScoring()
        {
            Console.WriteLine("Testing scoring...");
            string    applicantId = "prospect_20140425142614_5UXIDTMYAUZT611H";
            Applicant applicant   = ApplicantRepository.GetApplicant(applicantId, ApiKey);

            Console.WriteLine(applicant.first_name + " " + applicant.last_name + "'s resume is being scored...");

            string         resume  = FileService.GetTextFromUrl(ResumeFolder, applicant.resume_link);
            ScoringService scoring = new ScoringService(resume);
            var            report  = scoring.Score();

            //print the interesting stats
            foreach (WordStat stat in report.GetItemsOfSignificance())
            {
                Console.WriteLine("Word: " + stat.Word + " Count: " + stat.Count + " Weight: " + stat.Weight + " " + stat.Type);
            }

            Console.WriteLine("SCORE: " + report.GetScore());
            Console.WriteLine("Done testing scoring.");
        }
예제 #14
0
        public MainForm(Referee referee)
        {
            InitializeComponent();
            this.referee = referee;
            string connStr = ConfigurationManager.ConnectionStrings["triathlon"].ToString();
            //IDictionary<string, string> props = new SortedList<string, string>();
            IDictionary <string, string> props = DBUtils.getProps();
            ParticipantRepository        participantRepository = new ParticipantRepository(props);
            ScoreRepository scoreRepository = new ScoreRepository(props);
            ScoringService  scoringService  = new ScoringService(participantRepository, scoreRepository);

            this.scoringService = scoringService;
            DataTable dataTable = scoringService.getParticipantsWithScore().Tables[0];

            participantsGridView.DataSource = dataTable;
            scores = new Dictionary <int, int>();
            foreach (int key in scoringService.getIds())
            {
                scores.Add(key, 0);
            }
            refereeNameLabel.Text = "Hello " + this.referee.Username;
        }
예제 #15
0
 public HomeController(ILogger <HomeController> logger,
                       ScoringService scoringService)
 {
     _logger         = logger;
     _scoringService = scoringService;
 }