public void Should_throw_error_when_text_is_invalid(string text) { var cmd = new CreateTome { Text = text, BaseItemId = 1 }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo("No text was provided for the tome")); }
public void Should_throw_error_when_base_item_id_is_invalid(int id) { var cmd = new CreateTome { Text = "tome text", BaseItemId = id }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo("Base item id must be greater than 0")); }
public void Should_create_new_tome() { var item = new ItemSourceBuilder().With(cr => cr.Id, 195).BuildAndSave(); var cmd = new CreateTome { Text = "This is a tome.", BaseItemId = item.Id }; Assert.That(Repository.Execute(cmd), Is.GreaterThan(0)); }
public virtual ActionResult CreateSend(CreateTome cmd) { var tomeId = DomainRegistry.Repository.Execute(cmd); var tome = DomainRegistry.Repository.FindSingle(new GetTome { TomeId = tomeId }); TempData["Result"] = "Tome for " + tome.BaseItem.FriendlyName + " created successfully."; return(RedirectToAction(MVC.Tome.List())); }
public void Should_throw_error_when_base_item_is_not_found() { const int id = 1; var cmd = new CreateTome { Text = "tome text", BaseItemId = id }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo($"Base item with Id {id} could not be found")); }