Ejemplo n.º 1
0
        public async Task MatchDayIsUpdatedCorrectly()
        {
            var game     = GetGame();
            var matchDay = GetMatchDay();

            var mockPlayerRepository = new Mock <IPlayerRepository>();

            mockPlayerRepository.SetupSequence(
                repo => repo.Find(It.IsAny <Expression <Func <Player, bool> > >()))
            .Returns(Task.FromResult(new List <Player>()
            {
                game.PlayerOne
            }.AsQueryable()))
            .Returns(Task.FromResult(new List <Player>()
            {
                game.PlayerTwo
            }.AsQueryable()));

            mockPlayerRepository.Setup(
                repo => repo.AddOrUpdate(It.IsAny <Player>()))
            .Returns(Task.FromResult(new Player()));

            var handicapUpdateService = new HandicapUpdateService(mockPlayerRepository.Object);

            matchDay = await handicapUpdateService.UpdateMatchDayHandicaps(matchDay);

            matchDay.Should().NotBeNull();
        }
Ejemplo n.º 2
0
        public void HandicapIsUpdatedCorrectly()
        {
            var mockPlayerRepository  = new Mock <IPlayerRepository>();
            var handicapUpdateService = new HandicapUpdateService(mockPlayerRepository.Object);
            var game = GetGame();

            game = handicapUpdateService.UpdatePlayerHandicap(game);
            game.PlayerOne.Handicap.Should().Be(50);
            game.PlayerTwo.Handicap.Should().Be(60);
        }
Ejemplo n.º 3
0
        public void HandicapDoesNotGoAbove90()
        {
            var mockPlayerRepository  = new Mock <IPlayerRepository>();
            var handicapUpdateService = new HandicapUpdateService(mockPlayerRepository.Object);
            var game = GetGame();

            game.PlayerTwo.Handicap = 90;

            game = handicapUpdateService.UpdatePlayerHandicap(game);
            game.PlayerOne.Handicap.Should().Be(50);
            game.PlayerTwo.Handicap.Should().Be(90);
        }