public void Test_if_player_can_be_created_without_team() { List<Team> teams = null; Player player = new Player() { Id = 1, Name = "Hans", Teams = teams }; DTOPlayerConverter dtoPlayerConverter = new DTOPlayerConverter(); DTOPlayer dtoPlayer = dtoPlayerConverter.Convert(player); Assert.IsNull(teams); Assert.NotNull(dtoPlayer); Assert.AreEqual(dtoPlayer.Id, player.Id); }
public void Test_if_Group_with_team_and_tournaments_can_be_converted_to_DTO() { Player player = new Player() { Id = 1, Name = "Søren" }; Player player2 = new Player() { Id = 2, Name = "Lars" }; Player player3 = new Player() { Id = 3, Name = "Peter" }; Player player4 = new Player() { Id = 4, Name = "Poul" }; List<Player> PlayersForTeam1 = new List<Player>() { player, player2 }; List<Player> PlayersForTeam2 = new List<Player>() { player3, player4 }; Team Team1 = new Team() { Id = 1, Name = "Awesome", Players = PlayersForTeam1 }; Team Team2 = new Team() { Id = 1, Name = "More Awesome", Players = PlayersForTeam2 }; Tournament tournament1 = new Tournament() { Id = 1, Name = "Warhammer", Game = new Game() { Id = 1, Name = "Wars", Genre = new Genre() { Id = 1, Name = "role" } }, StartDate = DateTime.Today, TournamentType = new TournamentType() { Id = 1, Type = "2vs2" } }; List<Team> teams = new List<Team> { Team1, Team2 }; Group group = new Group() { Id = 1, Name = "A", Teams = teams, Tournament = tournament1 }; DTOGroupConverter dtogroupConverter = new DTOGroupConverter(); DTOGroup dtoGroup = dtogroupConverter.Convert(group); Assert.IsNotNull(teams); Assert.AreEqual(dtoGroup.Id, 1); Assert.AreSame(Team1.Name, dtoGroup.DtoTeams[0].Name); Assert.Greater(dtoGroup.DtoTeams.Count, 0); Assert.AreEqual(dtoGroup.DtoTeams[0].Id, group.Teams[0].Id); Assert.AreEqual(dtoGroup.DtoTeams[1].Id, group.Teams[1].Id); Assert.AreEqual(dtoGroup.DtoTeams[0].Name, group.Teams[0].Name); Assert.AreEqual(dtoGroup.DtoTeams[1].Name, group.Teams[1].Name); Assert.AreEqual(dtoGroup.DtoTournament.Id, tournament1.Id); Assert.AreEqual(dtoGroup.DtoTournament.Name, tournament1.Name); Assert.AreEqual(dtoGroup.DtoTournament.StartDate, tournament1.StartDate); }
public void Test_if_Player_can_be_converted_to_DTO_with_teams() { List<Team> teams = new List<Team>(); Team team1 = new Team() { Id = 1, Name = "team one", Draw = 1, Loss = 2, Win = 2 }; Team team2 = new Team() { Id = 2, Name = "team two", Draw = 1, Loss = 2, Win = 2 }; teams.Add(team1); teams.Add(team2); Player player = new Player() { Id = 1, Name = "Ole", Teams = teams }; DTOPlayerConverter dtoPlayerConverter = new DTOPlayerConverter(); DTOPlayer dtoPlayer = dtoPlayerConverter.Convert(player); Assert.NotNull(teams); Assert.NotNull(dtoPlayer.DtoTeams); Assert.NotNull(dtoPlayer); Assert.AreEqual(dtoPlayer.Id, player.Id); Assert.Greater(dtoPlayer.DtoTeams.Count, 0); Assert.Greater(teams.Count, 0); Assert.LessOrEqual(dtoPlayer.DtoTeams.Count, 2); Assert.LessOrEqual(teams.Count, 2); }
public void Test_if_two_players_can_be_added_to_one_team() { int id = 1; string name = "Ole"; Player player = new Player() { Id = id, Name = name }; int id2 = 2; string name2 = "Ulla"; Player player2 = new Player() { Id = id2, Name = name2 }; team.Players = new List<Player>() { player, player2 }; Assert.NotNull(team.Players); Assert.Greater(team.Players.Count, 0); Assert.NotNull(team.Players[0]); Assert.NotNull(team.Players[1]); Assert.AreEqual(player, team.Players[0]); Assert.AreEqual(player2, team.Players[1]); }
public void Test_if_tournament_can_be_converted_with_groups_and_type_and_a_game() { DTOTournament dtoTournament = new DTOTournament(); TournamentType tournamentType = new TournamentType() { Id = 1, Type = "2vs2" }; Genre genre = new Genre() { Id = 1, Name = "wars"}; Player player1 = new Player() { Id = 1, Name = "Hans"}; Player player2 = new Player() {Id = 2, Name = "Ole"}; Player player3 = new Player() { Id = 3, Name = "Lars" }; Player player4 = new Player() { Id = 4, Name = "Peter" }; List<Player> players1 = new List<Player>() {player1, player2}; List<Player> players2 = new List<Player>() { player3, player4 }; Team team1 = new Team() {Id = 1, Name = "team1", Players = players1, Win = 2, Draw = 2, Loss = 1}; Team team2 = new Team() { Id = 1, Name = "team2", Players = players2, Win = 3, Draw = 0, Loss = 1 }; List<Team> teams1 = new List<Team>() {team1, team2}; Group group1 = new Group() { Id = 1, Name = "Hans og Ole", Teams = teams1}; Group group2 = new Group() { Id = 1, Name = "Lars og Peter", Teams = teams1}; List<Group> groups = new List<Group>() {group1, group2}; Game game = new Game() { Id = 1, Name = "Warhammer", Genre = genre}; Match match = new Match() {Id = 1, AwayTeam = team1, HomeTeam = team2, Round = "blabla"}; DTOTournamentConverter dtoTournamentConverter = new DTOTournamentConverter(); Tournament tournament = new Tournament() { Id = 1, Name = "Tournament One", StartDate = DateTime.Today, TournamentType = tournamentType, Groups = groups, Game = game, Matches = new List<Match>() { match} }; dtoTournament = dtoTournamentConverter.Convert(tournament); Assert.IsNotNull(tournament.TournamentType); Assert.AreEqual(tournament.Id, dtoTournament.Id); Assert.AreEqual(tournamentType.Id, dtoTournament.DTOTournamentType.Id); Assert.IsNotNull(groups); Assert.IsNotNull(dtoTournament.DtoGroups); Assert.AreEqual(groups.Count, dtoTournament.DtoGroups.Count); Assert.IsNotNull(dtoTournament.DtoGame); Assert.AreEqual(dtoTournament.DtoGame.Id, game.Id); }
public void SetupList(Player player, List<Team> listOfTeams ) { ListWithOutAdded = new List<Team>(); foreach (var team in listOfTeams) { ListWithOutAdded.Add(team); } TeamsAdded = player.Teams; foreach (var tm in listOfTeams) { foreach (var tmA in TeamsAdded) { if (tm.Id == tmA.Id) { ListWithOutAdded.Remove(tm); } } } }
public void SetUp() { var config = new HttpConfiguration(); var request = new HttpRequestMessage(HttpMethod.Post, "http://dragonapi.devjakobsen.dk/api/team"); var route = config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}"); var routeData = new HttpRouteData(route, new HttpRouteValueDictionary { { "controller", "team" } }); teamController = new TeamController(); UrlHelper urlHelper = new UrlHelper(request); teamController.ControllerContext = new HttpControllerContext(config, routeData, request); teamController.Request = request; teamController.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config; teamController.Request.Properties[HttpPropertyKeys.HttpRouteDataKey] = routeData; teamController.Url = urlHelper; var response = playerController.Get(1); var contentResult = response as OkNegotiatedContentResult<DTOPlayer>; var groupResponse = groupController.Get(1); var groupContentResult = groupResponse as OkNegotiatedContentResult<DTOGroup>; DTOGroup DtoGroup = groupContentResult.Content; Group groupFromDb = new Group(); groupFromDb.Name = DtoGroup.Name; groupFromDb.Id = DtoGroup.Id; List<Group> groups = new List<Group>() { groupFromDb }; DTOPlayer Dtoplayer = contentResult.Content; playerFromDb = new Player(); playerFromDb.Name = Dtoplayer.Name; playerFromDb.Id = Dtoplayer.Id; List<Player> players = new List<Player>() {playerFromDb}; team = new Team() { Name = "Integration Test Team", Players = players, Groups = groups, Draw = 0, Win = 0, Loss = 0}; }
public void Start() { sceneManager = this; generator.Initialize(); player = new Entities.Player("Player", new Vector2(0, 0)); UI.MenuManager.CreateHUD(player); cam.SetFollower(player.entityObject); generator.SetPlayer(cam.gameObject); List <List <Crafting.Recipe> > recipes = Crafting.CraftingData.WORKBENCH.GetRecipes(new ItemStack[] { new ItemStack(Items.ItemData.WOOD, 4) }); foreach (var recipeList in recipes) { foreach (var recipe in recipeList) { Debug.Log("Result: " + recipe.result.GetItem().itemData.Name + "x" + recipe.result.GetAmount()); foreach (var ingredient in recipe.ingredients) { Debug.Log("\t" + ingredient.GetItem().itemData.Name + "x" + ingredient.GetAmount()); } } } }
public void TearDown() { playerController = null; player = null; }
public async void Test_if_a_team_can_be_added_to_a_player() { Player player1 = new Player() {Name = "TestPlayer1"}; Player player2 = new Player() {Name = "Testplayer2"}; WebApiService apiService = new WebApiService(); await playerController.Create(player1); await playerController.Create(player2); var players = await apiService.GetAsync<List<Player>>("api/player/"); var player1WithOutTeam = players.FirstOrDefault(a => a.Name == player1.Name); var player2WithOutTeam = players.FirstOrDefault(a => a.Name == player2.Name); List<Player> testList1 = new List<Player>() { player1WithOutTeam }; List<Player> testList2 = new List<Player>() { player2WithOutTeam }; Team teamOne = new Team() { Name = "TestTeam1", Draw = 0, Loss = 0, Win = 0, Players = testList1 }; Team teamTwo = new Team() { Name = "TestTeam2", Draw = 0, Loss = 0, Win = 0, Players = testList2 }; await apiService.PostAsync("api/team/", teamOne); await apiService.PostAsync("api/team/", teamTwo); var playerlist = await apiService.GetAsync<List<Player>>("api/player/"); var createdePlayer1 = playerlist.FirstOrDefault(a => a.Name == player1.Name); var createdePlayer2 = playerlist.FirstOrDefault(a => a.Name == player2.Name); Assert.IsNotNull(createdePlayer1); Assert.IsNotNull(createdePlayer2); int teamSizeBefore = createdePlayer1.Teams.Count; int teamId1ToRemove = createdePlayer1.Teams[0].Id; int teamId2ToRemove = createdePlayer2.Teams[0].Id; Team teamToAdd = await apiService.GetAsync<Team>("api/team/" + createdePlayer2.Teams[0].Id); await playerController.Add(teamToAdd.Id, createdePlayer1.Id); Player playerAfter = await apiService.GetAsync<Player>("api/player/" + createdePlayer1.Id); int teamSizeAfter = playerAfter.Teams.Count; Assert.AreNotEqual(teamSizeAfter, teamSizeBefore); await apiService.DeleteAsync<Team>("api/team/" + teamId1ToRemove); await apiService.DeleteAsync<Team>("api/team/" + teamId2ToRemove); await playerController.DeleteConfirmed(createdePlayer1.Id); await playerController.DeleteConfirmed(createdePlayer2.Id); }
public void SetUp() { playerController = new PlayerController(); player = new Player() { Name = "TestPlayer" }; }
public async void Test_if_create_with_missing_data_returns_create_view() { player = null; var result = await playerController.Create(player) as ViewResult; Assert.AreEqual("Create", result.ViewName); }
public void TearDown() { player = null; }
public void SetUp() { id = 1; name = "Dragon"; player = new Player() { Id = id, Name = name }; }
public void addPlayer(Player player) { _players.Add(player); }