public void Test_CreateGame() { //A simple test to provide a troubleshooting entry point for the process of creating a game GameHelpers gh = new GameHelpers(); string errorMsg = ""; Game newGame = gh.CreateGame(1, "normal", out errorMsg); //string result = "1"; Assert.AreNotEqual(null, newGame, "New game was not created"); }
public HttpResponseMessage NewGame(int userId, string gameMode) { //check for valid user id if (userId < 1) { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Invalid UserId")); } string errorMsg = ""; Game newGame = gh.CreateGame(userId, gameMode, out errorMsg); if (errorMsg != "") { return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Failed to create new game: Error was: " + errorMsg)); } else { var message = Request.CreateResponse(HttpStatusCode.Created, newGame); message.Headers.Location = new Uri(Request.RequestUri + newGame.GameId.ToString()); return(message); } }