public void Should_throw_error_when_RestockItem_id_is_invalid(int id) { var cmd = new DeleteRestockItem { RestockItemId = id }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo("RestockItem Id must be greater than 0")); }
public void Should_throw_error_when_RestockItem_is_not_found() { const int id = 1; var cmd = new DeleteRestockItem { RestockItemId = id }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo($"RestockItem with ID {id} was not found")); }
public virtual ActionResult Delete(int id) { var cmd = new DeleteRestockItem { RestockItemId = id }; DomainRegistry.Repository.Execute(cmd); TempData["Result"] = "RestockItem Id " + id + " deleted successfully."; return(RedirectToAction(MVC.RestockItem.List())); }
public void Should_delete_RestockItem() { new RestockItemBuilder().With(cr => cr.Id, 7) .BuildAndSave(); var cmd = new DeleteRestockItem { RestockItemId = 7 }; Assert.That(() => Repository.Execute(cmd), Throws.Nothing); Assert.That(DataContext.AsQueryable <RestockItem>(), Is.Empty); }