public void AddShouldAddNewEquipmentToRepository()
 {
     EquipmentController controller = new EquipmentController(repo);
     Equipment equip3 = new Equipment() { EquipmentID = 3, Name = "gamma", Category = 0, Weight = 12.7, Location = "wherever", IsDefault = true };
     controller.Add(equip3);
     ViewResult result = controller.Index() as ViewResult;
     Assert.IsNotNull(result);
     IEnumerable<Equipment> model = result.Model as IEnumerable<Equipment>;
     Assert.AreEqual(3, model.Count());
     Assert.IsTrue(model.Contains(equip3));
 }
 public ActionResult Add(Equipment equipmentModel)
 {
     equipmentRepository.Add(equipmentModel);
     equipmentRepository.Commit();
     return RedirectToAction("Index");
 }
 public ActionResult Edit(Equipment equipmentModel)
 {
     Equipment item = equipmentRepository.FindBy(x => x.EquipmentID == equipmentModel.EquipmentID).Single();
     item.EquipmentID = equipmentModel.EquipmentID;
     item.Category = equipmentModel.Category;
     item.Name = equipmentModel.Name;
     item.Weight = equipmentModel.Weight;
     item.Location = equipmentModel.Location;
     item.IsDefault = equipmentModel.IsDefault;
     equipmentRepository.Commit();
     return RedirectToAction("Index");
 }
 public void EditShouldChangePreviouslyAddedEquipment()
 {
     EquipmentController controller = new EquipmentController(repo);
     Equipment equip2changed = new Equipment() { EquipmentID = 2, Name = "theta", Category = 0, Weight = 4.65, Location = "somewhere", IsDefault = true };
     controller.Edit(equip2changed);
     ViewResult result = controller.Index() as ViewResult;
     Assert.IsNotNull(result);
     IEnumerable<Equipment> model = result.Model as IEnumerable<Equipment>;
     Assert.AreEqual(2, model.Count());
     Equipment temp = model.ElementAt(1);
     Assert.AreEqual(equip2changed.EquipmentID, temp.EquipmentID);
     Assert.AreEqual(equip2changed.Name, temp.Name);
     Assert.AreEqual(equip2changed.Category, temp.Category);
     Assert.AreEqual(equip2changed.Weight, temp.Weight);
     Assert.AreEqual(equip2changed.Location, temp.Location);
     Assert.AreEqual(equip2changed.IsDefault, temp.IsDefault);
 }