public void GetFirstLeagueWithSpaces_NoLeagueFound_ReturnsNull()
        {
            // Arrange
            var league1 = new League { PlayerRegistrations = new List<LeaguePlayer> { new LeaguePlayer(), new LeaguePlayer() } };

            var association = new PredsAssociation { PlayersPerLeague = 2, Leagues = new List<League> { league1 } };

            var fakeRepository = new Mock<IPredsAssociationRepository>();
            fakeRepository.Setup(x => x.Load(1)).Returns(association);

            var service = new PredsAssociationService(fakeRepository.Object, null);

            // Act
            var result = service.GetFirstLeagueWithSpaces(1);

            // Assert
            Assert.That(result, Is.Null);
        }
Esempio n. 2
0
        public ManageLeagueViewModel(League league, int playersPerLeague, bool isTopLeague, bool isBottomLeague)
        {
            Id = league.LeagueId;
            Name = league.LeagueName;
            Players = new Player[playersPerLeague];
            IsTopLeague = isTopLeague;
            IsBottomLeague = isBottomLeague;

            if (league.PlayerRegistrations != null)
            {
                IsSpacesAvailable = league.PlayerRegistrations.Count() != playersPerLeague;

                foreach (var player in league.PlayerRegistrations)
                {
                    Players.Add(new Player(player.User));
                }
            }
            else
                IsSpacesAvailable = true;
        }