public ActionResult VehicleSummary() { var vehicles = _starWarsService.GetAllVehicles(); var model = Mapper.Map <VehicleSummaryViewModel>(vehicles); return(View(model)); }
public void TestGetAllVehicles() { var vehiclesJson = "{\"count\": 39,\"next\": null,\"previous\": null,\"results\": [{\"name\": \"Sand Crawler\",\"model\": \"Digger Crawler\",\"manufacturer\": \"Corellia Mining Corporation\",\"cost_in_credits\": \"150000\",\"length\": \"36.8\",\"max_atmosphering_speed\": \"30\",\"crew\": \"46\",\"passengers\": \"30\",\"cargo_capacity\": \"50000\",\"consumables\": \"2 months\",\"vehicle_class\": \"wheeled\",\"pilots\": [],\"films\": [\"https://swapi.co/api/films/5/\",\"https://swapi.co/api/films/1/\"]}]}"; _mockHttpService.JsonResponses["https://swapi.co/api/vehicles/"] = vehiclesJson; var vehicles = _starWarsService.GetAllVehicles(); Assert.AreEqual(vehicles.Count, 1); var vehicle = vehicles.Find(x => x.Name == "Sand Crawler"); Assert.AreEqual(vehicle.Model, "Digger Crawler"); Assert.AreEqual(vehicle.Manufacturer, "Corellia Mining Corporation"); Assert.AreEqual(vehicle.CostInCredits, "150000"); Assert.AreEqual(vehicle.Length, "36.8"); Assert.AreEqual(vehicle.MaxAtmospheringSpeed, "30"); Assert.AreEqual(vehicle.Crew, "46"); Assert.AreEqual(vehicle.Passengers, "30"); Assert.AreEqual(vehicle.CargoCapacity, "50000"); Assert.AreEqual(vehicle.Consumables, "2 months"); Assert.AreEqual(vehicle.VehicleClass, "wheeled"); Assert.AreEqual(vehicle.Pilots.Count, 0); Assert.AreEqual(vehicle.Films.Count, 2); }