public JsonResult metro7Post() { string ulaznaDatoteka = (string)TempData["Metro"]; // Mapa metro = new Mapa("ZagrebMetro", ulaznaDatoteka); List<Ruta> Lista = new List<Ruta>() { new Ruta(new Kvart("MAKSIMIR"), new Kvart("SIGET"),5), new Ruta(new Kvart("SIGET"),new Kvart("SPANSKO"),4), new Ruta(new Kvart("SPANSKO"),new Kvart("MEDVESCAK"),8), new Ruta(new Kvart("MEDVESCAK"),new Kvart("SPANSKO"), 8), new Ruta(new Kvart("MEDVESCAK"),new Kvart("DUBRAVA"),6), new Ruta(new Kvart("MAKSIMIR"), new Kvart("MEDVESCAK"),5), new Ruta(new Kvart("SPANSKO"),new Kvart("DUBRAVA"), 2), new Ruta(new Kvart("DUBRAVA"),new Kvart("SIGET"),3), new Ruta(new Kvart("MAKSIMIR"),new Kvart("DUBRAVA"),7) }; //List<Ruta> Lista = metro.KonstrukcijaRuta(); List<Ruta> r = new List<Ruta>(); foreach (Ruta ru in Lista) { r.Add(ru); } MyModel2 model2 = new MyModel2() { distance = 0 }; //model2.NajkracaRuta(Lista, model) //return View("zagrebPost"); return Json(model2, JsonRequestBehavior.AllowGet); }
public void metro5PostTest() { //Arange MyModel4 request1 = new MyModel4() { stations = new List<Kvart> { new Kvart("MAKSIMIR"), new Kvart("SPANSKO") } }; MyModel2 expected1 = new MyModel2() { distance = 9 }; MyModel4 request2 = new MyModel4() { stations = new List<Kvart> { new Kvart("MAKSIMIR"), new Kvart("SPANSKO") } }; MyModel2 expected2 = new MyModel2() { distance = 9 }; METRO5Controller controller = new METRO5Controller(); //Act // JsonResult result1 = controller.metro5Post(request1) as JsonResult; // string Json1 = new JavaScriptSerializer().Serialize(result1.Data); string expectedJson1 = new JavaScriptSerializer().Serialize(expected1); // Assert // Assert.IsNotNull(result1); // Assert.AreEqual(expectedJson1, Json1); //JsonResult result2 = controller.metro5Post(request2) as JsonResult; //string Json2 = new JavaScriptSerializer().Serialize(result2.Data); string expectedJson2 = new JavaScriptSerializer().Serialize(expected2); // Assert //Assert.IsNotNull(result2); // Assert.AreEqual(expectedJson2, Json2); }
public ActionResult zagrebPost(MyModel1 request) { string ulaznaDatoteka = (string)TempData["Metro"]; // Mapa metro = new Mapa("ZagrebMetro", ulaznaDatoteka); List<Ruta> Lista = new List<Ruta>() { new Ruta(new Kvart("MAKSIMIR"), new Kvart("SIGET"),5), new Ruta(new Kvart("SIGET"),new Kvart("SPANSKO"),4), new Ruta(new Kvart("SPANSKO"),new Kvart("MEDVESCAK"),8), new Ruta(new Kvart("MEDVESCAK"),new Kvart("SPANSKO"), 8), new Ruta(new Kvart("MEDVESCAK"),new Kvart("DUBRAVA"),6), new Ruta(new Kvart("MAKSIMIR"), new Kvart("MEDVESCAK"),5), new Ruta(new Kvart("SPANSKO"),new Kvart("DUBRAVA"), 2), new Ruta(new Kvart("DUBRAVA"),new Kvart("SIGET"),3), new Ruta(new Kvart("MAKSIMIR"),new Kvart("DUBRAVA"),7) }; //List<Ruta> Lista = metro.KonstrukcijaRuta(); List<Ruta> r = new List<Ruta>(); foreach (Ruta ru in Lista) { r.Add(ru); } MyModel1 model = new MyModel1() { stations = new string[] { "" } }; model.stations = request.stations; MyModel2 model2 = new MyModel2() { distance = 0 }; model2.distance = model.DuljinaPuta(r); return View("zagrebPost"); //return Json(model2 ,JsonRequestBehavior.AllowGet); }
public void zagrebPostTest() { //Arange MyModel1 request = new MyModel1() { stations = new string[] { "MAKSIMIR", "DUBRAVA" } }; MyModel2 expected = new MyModel2() { distance = 7 }; zagrebmetroController controller = new zagrebmetroController(); //Act JsonResult result = controller.zagrebPost(request) as JsonResult; string Json = new JavaScriptSerializer().Serialize(result.Data); string expectedJson = new JavaScriptSerializer().Serialize(expected); // Assert Assert.IsNotNull(result); Assert.AreEqual(expectedJson, Json); }