private void AddPlayers(PlayPlaces places, int count) { for (int i = 0; i < count; i++) { var player = new Player(Guid.NewGuid(), i.ToString()); places.PlantPlayer(player); } }
private void AddAndRemovePlayersTestInternal(PlayPlaces places, int maxPlaces) { AddPlayers(places, maxPlaces); Assert.Equal(maxPlaces, places.Players.Count); Assert.True(places.IsFull); Assert.Throws <TrueFalseGameException>(() => { places.PlantPlayer(new Player(Guid.NewGuid(), "Test")); }); var player = places.Players.Last().Player; Assert.Throws <TrueFalseGameException>(() => { places.PlantPlayer(player); }); places.RemovePlayer(player); Assert.Equal(maxPlaces - 1, places.Players.Count); Assert.Null(places.Players.FirstOrDefault(p => p.Player.Id == player.Id)); player = places.Players.Last().Player; Assert.Throws <TrueFalseGameException>(() => { places.PlantPlayer(player); }); RemoveAllPlayers(places); Assert.Equal(0, places.Players.Count); Assert.Throws <TrueFalseGameException>(() => { places.RemovePlayer(player); }); }
private void PlaceNumbersTestInternal(PlayPlaces places, int maxPlaces) { AddPlayers(places, maxPlaces); CheckPlaceNumbers(places); var player = places.Players.First().Player; places.RemovePlayer(player); CheckPlaceNumbers(places); places.PlantPlayer(player); places.RemovePlayer(GetMiddlePlayer(places)); CheckPlaceNumbers(places); }