public void Save() { //Arrage ItemCategory ic = new ItemCategory(); ic.Name = "Test"; ic.Description = "Tests"; ic.Status = new StatusRepository(context).FindById(1); ic.CreatedDateTime = DateTime.Now; //Act var result = itemCategoryService.Save(ic); //Assert Assert.AreEqual("Test", result.Name); itemCategoryRepository.Delete(ic); }
public void TestCleanup() { List <ItemCategory> list = context.ItemCategory.Where(x => x.Name == "TEST").ToList(); foreach (ItemCategory i in list) { itemcategoryRepository.Delete(i); } }
// GET: ItemCategory/Delete/5 public ActionResult Delete(int id) { try { ItemCategoryRepository repository = new ItemCategoryRepository(); repository.Delete(id); return(RedirectToAction("GetAll")); } catch { return(View()); } }
public void SaveAndDeleteTestNew() { // Save new object into DB // Arrange var itemCategory = new ItemCategory { ItemCategoryId = 999999, CreatedDateTime = DateTime.Now }; // Act var saveResult = itemCategoryRepository.Save(itemCategory); // Assert Assert.IsInstanceOfType(saveResult, typeof(ItemCategory)); // Delete saved object from DB // Act itemCategoryRepository.Delete(saveResult); // Assert Assert.IsNull(itemCategoryRepository.FindById(999999)); }