public void SetUp()
        {

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


            gameController = new GameController();
            UrlHelper urlHelper = new UrlHelper(request);
            gameController.ControllerContext = new HttpControllerContext(config, routeData, request);
            gameController.Request = request;
            gameController.Request.Properties[HttpPropertyKeys.HttpConfigurationKey] = config;
            gameController.Request.Properties[HttpPropertyKeys.HttpRouteDataKey] = routeData;
            gameController.Url = urlHelper;
            genreController = new GenreController();
            var response = genreController.Get(1);
            var contentResult = response as OkNegotiatedContentResult<DTOGenre>;

            DTOGenre DtoGenre = contentResult.Content;
            genrefromDb = new Genre();
            genrefromDb.Name = DtoGenre.Name;
            genrefromDb.Id = DtoGenre.Id;
            game = new Game() { Name = "Integration Test Game", Genre = genrefromDb };
        }
 public void Test_if_tournament_has_a_game()
 {
     int id = 1;
     string name = "Game 1";
     Game game = new Game() { Id = id, Name = name };
     tournament.Game = game;
     Assert.NotNull(tournament.Game);
     Assert.AreEqual(tournament.Game.Id, id);
 }
 // POST: api/Game
 public HttpResponseMessage Post(Game game)
 {         
     game = gameRepository.Create(game);
     DTOGame dtoGame = dtoGameConverter.Convert(game);
     var response = Request.CreateResponse<DTOGame>(HttpStatusCode.Created, dtoGame);
     string uri = Url.Link("DefaultApi", new { id = dtoGame.Id });
     response.Headers.Location = new Uri(uri);
     return response;
 }
Beispiel #4
0
 public void Test_if_a_genre_can_be_in_many_games()
 {
     Game game1 = new Game() { Id = 1, Name = "warhammer", Genre = genre };
     Game game2 = new Game() { Id = 2, Name = "warFlower", Genre = genre };
     genre.Games = new List<Game>() { game1, game2 };
     Assert.IsNotNull(genre.Games);
     Assert.AreSame(game1, genre.Games[0]);
     Assert.AreSame(game2, genre.Games[1]);
 }
 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/");
 }
Beispiel #6
0
 public static void PlayGame(Game game)
 {
     try
     {
         Process.Start(game.Exe);
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
         Console.ReadKey();
     }
 }
Beispiel #7
0
        public static void Create(Game game, string path)
        {
            XDocument doc = XDocument.Load(path);

            doc.Root.Add(new XElement("Game", new XAttribute("Title", game.Title),
                    new XAttribute("ID", game.ID),
                    new XAttribute("Genre", game.Genre.ToString()),
                    new XElement("Logo", game.Logo),
                    new XElement("Description", game.Description),
                    new XElement("Path", game.Exe)));

            doc.Save(path);
        }
 public void Test_if_Genre_with_games_can_be_converted_to_DTO()
 {
     Game game1 = new Game() {Id = 1, Name = "Warhammer"};
     Game game2 = new Game() { Id = 1, Name = "Warhammer 40k" };
     List<Game> games = new List<Game>();
     games.Add(game1);
     games.Add(game2);
     Genre genre = new Genre() { Id = 1, Name = "Figur", Games = games };
     DTOGenreConverter dtoGenreConverter = new DTOGenreConverter();
     DTOGenre dtoGenre = dtoGenreConverter.Convert(genre);
     Assert.IsNotNull(games);         
     Assert.AreEqual(dtoGenre.Id, genre.Id);
     Assert.AreSame(game1.Name, dtoGenre.DtoGames[0].Name);
     Assert.Greater(dtoGenre.DtoGames.Count, 0);
 }
Beispiel #9
0
        public Game Parse()
        {
            this.Read();
            this.game = new Game();
            for (var i = 0; i < this.lines.Length; i++)
            {
                var line = this.lines[i];
                //if (line.Contains("TRANSITIONING"))
                //    i = HandleTransitioning(i);
                if (line.Contains("ACTION_START"))
                    i = HandleActionStart(i);
                else if (line.Contains("TAG_CHANGE"))
                    i = HandleTagChange(i);
            }

            return this.game;
        }
Beispiel #10
0
 public int CompareTo(Game other)
 {
     return Title.CompareTo(other.Title);
 }
 public static void UpdateGame(Game game, GameCatalog catalog, int index)
 {
     catalog.Games[index] = game;
 }
 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);
 }
        // PUT: api/Game/5
        public void Put(int id, Game game)
        {
            game.Id = id;
            if (!gameRepository.Update(game)) throw new HttpResponseException(HttpStatusCode.NotFound);

        }
Beispiel #14
0
 public void TearDown()
 {
     game = null;
 }
Beispiel #15
0
 public void SetUp()
 {
    game = new Game() {Id = 1, Name = "Game 1"}; 
 }
Beispiel #16
0
        /// <summary>
        /// Saves or updates a game
        /// </summary>
        /// <param name="game">A game</param>
        public void SaveOrUpdate(Game game)
        {
            if (game == null) {
                throw new ArgumentNullException("game");
            }

            this.Session.SaveOrUpdate(game);
        }
Beispiel #17
0
 public static void UpdateGame(Game game, string path)
 {
     XmlRepository.Update(game, path);
 }
Beispiel #18
0
 public static void SaveGame(Game game, string path)
 {
     XmlRepository.Create(game, path);
 }
Beispiel #19
0
        public static void Update(Game game, string path)
        {
            XDocument doc = XDocument.Load(path);

            foreach (XElement elem in doc.Root.Elements())
            {
                foreach (XAttribute attr in elem.Attributes())
                {
                    if (attr.Value == game.ID)
                    {
                        elem.Remove();
                        doc.Root.Add(new XElement("Game", new XAttribute("Title", game.Title),
                    new XAttribute("ID", game.ID),
                    new XAttribute("Genre", game.Genre.ToString()),
                    new XElement("Logo", game.Logo),
                    new XElement("Description", game.Description),
                    new XElement("Path", game.Exe)));
                    }
                }
            }

            doc.Save(path);
        }
 public static void AddGame(Game game, GameCatalog catalog)
 {
     if (!catalog.Games.Contains(game))
         catalog.Games.Add(game);
 }
 public static void DeleteGame(Game game, GameCatalog catalog)
 {
     catalog.Games.Remove(game);
 }
Beispiel #22
0
 public void AddGame(Game game)
 {
     if (!Games.Contains(game))
         Games.Add(game);
 }