public void AccServiceCreate() { AccomodationServicesController controller = new AccomodationServicesController(); AccomodationService accs = new AccomodationService(); accs.AccomodationId = 1; accs.AccomodationServiceId = 1; accs.AccomodationServiceTypeId = 1; accs.Name = "BabyPlayground"; var result = controller.Create(accs); Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); }
public ActionResult AddServices(FormCollection collection) { string userid = User.Identity.GetUserId(); if (userid == null) { return View("Notfound"); } int accID = db.Users.FirstOrDefault(x => x.Id == userid).AccomodationId; var one = collection[0]; var two = collection[1]; var three = ""; try { three = collection[2] + "," + collection[3]; } catch { three = collection[2]; } string[] array1 =collection[1].Split(','); string[] array2 =three.Split(','); if (array1.Length == array2.Length) { for (int i = 0; i < array1.Length; i++) { AccomodationService service = new AccomodationService { AccomodationServiceTypeId = Convert.ToInt32(array2[i]), Name = array1[i], AccomodationId = accID }; if (service.AccomodationServiceTypeId != 0 && service.Name != "") { db.AccomodationServices.Add(service); db.SaveChanges(); } } return RedirectToAction("UpdateInfo"); } else { return View("Index"); } }
public void AccServiceEdit() { AccomodationServicesController controller = new AccomodationServicesController(); AccomodationService st = new AccomodationService(); st.AccomodationId = 1; st.AccomodationServiceId = 1; st.AccomodationServiceTypeId = 1; st.Name = "Baby"; var result = controller.Edit(st); Assert.IsInstanceOfType(result, typeof(RedirectToRouteResult)); Assert.IsTrue(controller.ModelState.IsValid); }