public void SetUp() { rLogic = new ReviewLogic(new TestReviewApiMethods()); bLogic = new BreweryLogic(new TestBreweryApiMethods()); bLogic.PostBrewery(brewery); controller = new ReviewController(rLogic, bLogic); }
public void Edit_Test_ValidInput() { // Arrange BreweryViewModel oldBrewery = CreateBreweryFromForm(collection); logic.PostBrewery(oldBrewery); oldBrewery = logic.GetBreweries().FirstOrDefault(); FormCollection newCollection = new FormCollection(); foreach (var i in collection.AllKeys) { newCollection.Add(i, collection.GetValue(i).AttemptedValue); } newCollection["Description"] = "new description"; // Act RedirectToRouteResult result = controller.Edit(oldBrewery.BreweryID, newCollection) as RedirectToRouteResult; // Assert BreweryViewModel newBrewery = logic.GetBreweries().FirstOrDefault(); Assert.AreNotEqual(newBrewery.Description, collection["Description"]); }
public ActionResult Create(FormCollection collection) { if (ModelState.IsValid) { try { var state = new State { StateID = 10, StateAbbr = "Fl" }; BreweryViewModel brewery = new BreweryViewModel { Name = collection["Name"], Description = collection["Description"], ImageURL = collection["ImageURL"], Address = collection["Address"], ZipCode = collection["ZipCode"], StateID = 10, //They should only be able to pick florida right now. Maybe still show the text field but make it uneditable PhoneNumber = collection["PhoneNumber"], BusinessHours = collection["BusinessHours"], HasTShirt = Convert.ToBoolean(collection["HasTShirt"].Split(',')[0]), HasMug = Convert.ToBoolean(collection["HasMug"].Split(',')[0]), HasGrowler = Convert.ToBoolean(collection["HasGrowler"].Split(',')[0]), HasFood = Convert.ToBoolean(collection["HasFood"].Split(',')[0]), AverageRating = 0, State = state }; logic.PostBrewery(brewery); return(RedirectToAction("Breweries")); } catch (Exception e) { return(View("Caught Exception")); } } else { return(View("Invalid Model State")); } }