public void Should_throw_error_when_tome_id_is_invalid(int id) { var cmd = new DeleteTome { TomeId = id }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo("Tome Id must be greater than 0")); }
public void Should_throw_error_when_tome_is_not_found() { const int id = 1; var cmd = new DeleteTome { TomeId = id }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo($"Tome with ID {id} was not found")); }
public virtual ActionResult Delete(int id) { var cmd = new DeleteTome { TomeId = id }; DomainRegistry.Repository.Execute(cmd); TempData["Result"] = "Tome Id " + id + " deleted successfully."; return(RedirectToAction(MVC.Tome.List())); }
public void Should_delete_tome() { new TomeBuilder().With(cr => cr.Id, 7) .With(cr => cr.Text, "First Tome") .With(cr => cr.BaseItem, new ItemSourceBuilder().With(cr => cr.Id, 195).BuildAndSave()) .BuildAndSave(); var cmd = new DeleteTome { TomeId = 7 }; Assert.That(() => Repository.Execute(cmd), Throws.Nothing); Assert.That(DataContext.AsQueryable <Tome>(), Is.Empty); }