public ActionResult GetPlanet(int planetId) { var planet = _starWarsService.GetPlanetById(planetId); var model = Mapper.Map <SinglePlanetViewModel>(planet); return(View(model)); }
public ActionResult GetPlanetById(int planetid) { // TODO: Implement this controller action Planet planet = _starWarsService.GetPlanetById(planetid).Result; var model = _viewMapperHelper.PlanetMapper(planet); return(View(model)); }
public void TestGetPlanetById() { var responseJson = "{\"name\": \"Alderaan\", \"rotation_period\": \"24\", \"orbital_period\": \"364\", \"diameter\": \"12500\", \"climate\": \"temperate\",\"gravity\": \"1 standard\",\"terrain\": \"grasslands, mountains\",\"surface_water\": \"40\",\"population\": \"2000000000\",\"residents\": [\"1\",\"2\"],\"films\": [\"1\"]}"; var planetId = 1; _mockHttpService.JsonResponses[$"https://swapi.co/api/planets/{planetId}"] = responseJson; var planet = _starWarsService.GetPlanetById(1); // Make sure that all properties are accurately translated to our model Assert.AreEqual(planet.Name, "Alderaan"); Assert.AreEqual(planet.LengthOfDay, "24"); Assert.AreEqual(planet.LengthOfYear, "364"); Assert.AreEqual(planet.Diameter, "12500"); Assert.AreEqual(planet.Climate, "temperate"); Assert.AreEqual(planet.Gravity, "1 standard"); Assert.AreEqual(planet.Terrain, "grasslands, mountains"); Assert.AreEqual(planet.SurfaceWaterPercentage, "40"); Assert.AreEqual(planet.Population, "2000000000"); Assert.AreEqual(planet.Residents.Length, 2); Assert.AreEqual(planet.Films.Length, 1); }