public void Test_if_TournamentType_can_be_converted_and_fail()
 {
     DTOTournamentType dtoTournamentType = new DTOTournamentType();
     DTOTournamentTypeConverter dtoTournamentTypeConverter = new DTOTournamentTypeConverter();
     TournamentType tournamentType = new TournamentType() { Id = 1, Type = "War Hammer" };
     dtoTournamentType = dtoTournamentTypeConverter.Convert(tournamentType);
    }
 // POST: api/TournamentType
 public HttpResponseMessage Post(TournamentType tournamentType)
 {
     tournamentType = tournamentTypeRepository.Create(tournamentType);
     var response = Request.CreateResponse<TournamentType>(HttpStatusCode.Created, tournamentType);
     string uri = Url.Link("DefaultApi", new { id = tournamentType.Id });
     response.Headers.Location = new Uri(uri);
     return response;
 }
Ejemplo n.º 3
0
 public void Test_if_tournament_has_a_tournamentType()
 {
     int id = 1;
     string type = "War Hammer";
     TournamentType tournementType = new TournamentType() { Id = id, Type = type };
     tournament.TournamentType = tournementType;
     Assert.NotNull(tournament.TournamentType);
     Assert.AreEqual(tournementType.Type, type);
 }
 public async Task PopulateCreateData()
 {
     if (Tournament == null) Tournament = new Tournament();
     if (Players == null) Players = await ServiceGateway.GetAsync<List<Player>>("api/Player/");
     if (SelectedPlayers == null) SelectedPlayers = new List<Player>();
     if (TournamentType == null) TournamentType = new TournamentType();
     if (TournamentTypes == null) TournamentTypes = await ServiceGateway.GetAsync<List<TournamentType>>("api/tournamenttype/");
     if (Game == null) Game = new Game();
     if (Games == null) Games = await ServiceGateway.GetAsync<List<Game>>("api/Game/");
 }
 public void Test_if_tournament_can_be_converted_with_a_type_and_fail()
 {
     DTOTournament dtoTournament = new DTOTournament();
     TournamentType tournamentType = new TournamentType() {Id = 1, Type = "2vs2"};
     DTOTournamentConverter dtoTournamentConverter = new DTOTournamentConverter();
     Tournament tournament = new Tournament()
     {
         Id = 1,
         Name = "Tournament One",
         StartDate = DateTime.Today,
         TournamentType = tournamentType
     };
     dtoTournament = dtoTournamentConverter.Convert(tournament);
    
 }
 public void Test_if_TournamentType_can_be_converted_with_tournaments()
 {
     DTOTournamentType dtoTournamentType = new DTOTournamentType();
     DTOTournamentTypeConverter dtoTournamentTypeConverter = new DTOTournamentTypeConverter();
     Tournament tournament = new Tournament() { Id = 1, Name = "warAT", Game = new Game() { Id = 1, Name = "wahamm", Genre = new Genre() { Id = 1, Name = "role" } }, StartDate = DateTime.Today };
     List<Tournament> tournaments = new List<Tournament>();
     tournaments.Add(tournament);
     TournamentType tournamentType =
         new TournamentType()
         {
             Id = 1,
             Type = "War Hammer",
             Tournaments = tournaments
         };
     dtoTournamentType = dtoTournamentTypeConverter.Convert(tournamentType);
     Assert.IsNotNull(dtoTournamentType.DtoTournaments);
     Assert.AreEqual(tournamentType.Id, dtoTournamentType.Id);
 }
        public void SetUp()
        {

            var config = new HttpConfiguration();
            var request = new HttpRequestMessage(HttpMethod.Post, "http://dragonapi.devjakobsen.dk/api/tournamentType");
            var route = config.Routes.MapHttpRoute("DefaultApi", "api/{controller}/{id}");
            var routeData = new HttpRouteData(route, new HttpRouteValueDictionary { { "controller", "tournamentType" } });


            tournamentTypeController = new TournamentTypeController();
            UrlHelper urlHelper = new UrlHelper(request);
            tournamentTypeController.ControllerContext = new HttpControllerContext(config, routeData, request);
            tournamentTypeController.Request = request;
            tournamentTypeController.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
            tournamentTypeController.Request.Properties[HttpPropertyKeys.HttpRouteDataKey] = routeData;
            tournamentTypeController.Url = urlHelper;

            tournamentType = new TournamentType() { Type = "Integration Test TournamentType" };

        }
 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 Test_if_tournament_can_be_converted_with_groups_and_type_and_fail()
        {
            DTOTournament dtoTournament = new DTOTournament();
            TournamentType tournamentType = new TournamentType() {Id = 1, Type = "2vs2"};
            List<Group> groups = new List<Group>();
            Group group1 = new Group() {Id = 1, Name = "Hans og Ole"};
            Group group2 = new Group() {Id = 1, Name = "Lars og Peter"};
            groups.Add(group1);
            groups.Add(group2);
            DTOTournamentConverter dtoTournamentConverter = new DTOTournamentConverter();
            Tournament tournament = new Tournament()
            {
                Id = 1,
                Name = "Tournament One",
                StartDate = DateTime.Today,
                TournamentType = tournamentType,
                Groups = groups
            };
            dtoTournament = dtoTournamentConverter.Convert(tournament);
           

        }
Ejemplo n.º 10
0
 public void TearDown()
 {
     tournementType = null;
 }
Ejemplo n.º 11
0
 public void SetUp()
 {
     tournementType = new TournamentType() { Id = 1, Type = "Play Off" };
 }
 // PUT: api/TournamentType/5
 public void Put(int id, TournamentType tournamentType)
 {
     tournamentType.Id = id;
     if (!tournamentTypeRepository.Update(tournamentType)) throw new HttpResponseException(HttpStatusCode.NotFound);
 }