public async void Test_if_edit_returns_a_view() { match = await apiService.GetAsync<Match>("api/match/" + 1); var result = await matchController.Edit(1) as ViewResult; Assert.IsNotNull(result); Assert.AreSame("Edit", result.ViewName); }
// PUT: api/Player/5 public void Put(int id, Match match) { //Player player; //entity.ToString(); match.Id = id; if (!matchRepository.Update(match)) throw new HttpResponseException(HttpStatusCode.NotFound); }
// POST: api/Player public HttpResponseMessage Post(Match match) { match = matchRepository.Create(match); var response = Request.CreateResponse<Match>(HttpStatusCode.Created, match); string uri = Url.Link("DefaultApi", new { id = match.Id }); response.Headers.Location = new Uri(uri); return response; }
public void TearDown() { apiService = null; matchController = null; match = null; }
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); }