public void PutPokemonTest() { pokemonController controller = new pokemonController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); string locationUrl = "http://localhost:8000/api/pokemon/"; var mockUrlHelper = new Mock <UrlHelper>(); mockUrlHelper.Setup(x => x.Link(It.IsAny <string>(), It.IsAny <object>())).Returns(locationUrl); controller.Url = mockUrlHelper.Object; var pokemon = new Models.Pokemon { name = "bulbasaur", image = "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/1.png", speed = 45, special_defense = 65, special_attack = 65, defense = 49, attack = 49, hp = 45, base_experience = 64, height = 7, weigh = 69, moves = new List <Models.Move> { new Models.Move { name = "razor-wind" }, new Models.Move { name = "echoed-voice" }, new Models.Move { name = "work-up" } }, abilities = new List <Models.Ability> { new Models.Ability { name = "chlorophyll" }, new Models.Ability { name = "overgrow" } } }; IHttpActionResult response = controller.PostPokemon(pokemon); var old_id = pokemon.id; response = controller.PutPokemon(pokemon); var new_id = pokemon.id; Assert.AreNotSame(new_id, old_id); }
public void GetAllPokemonsTest() { pokemonController controller = new pokemonController(); controller.Request = new HttpRequestMessage(); controller.Configuration = new HttpConfiguration(); string locationUrl = "http://localhost:8000/api/pokemon/"; var mockUrlHelper = new Mock <UrlHelper>(); mockUrlHelper.Setup(x => x.Link(It.IsAny <string>(), It.IsAny <object>())).Returns(locationUrl); controller.Url = mockUrlHelper.Object; IHttpActionResult response = controller.GetAllPokemons(6, 1); Assert.IsNotNull(response); }