public virtual ActionResult EditSend(UpdateRestockItem cmd) { DomainRegistry.Repository.Execute(cmd); TempData["Result"] = "RestockItem Id " + cmd.RestockItemId + " saved successfully."; return(RedirectToAction(MVC.RestockItem.List())); }
public void Should_throw_error_when_base_item_id_is_invalid(int id) { var cmd = new UpdateRestockItem { AmountBeforeRestock = 0, BaseItemId = 0, RestockItemId = restockItem.Id, AmountToRestockTo = 5, BotId = AIStatics.LindellaBotId }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo("Base item id must be greater than 0")); }
public RestockItem Update(UpdateRestockItem cmd, ItemSource baseItem, int botId) { Id = cmd.RestockItemId; BaseItem = baseItem; BotId = botId; AmountToRestockTo = cmd.AmountToRestockTo; AmountBeforeRestock = cmd.AmountBeforeRestock; return(this); }
public void Should_throw_error_when_base_item_is_not_found() { const int id = 17; var cmd = new UpdateRestockItem { AmountBeforeRestock = 0, BaseItemId = id, RestockItemId = restockItem.Id, AmountToRestockTo = 5, BotId = AIStatics.LindellaBotId }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo($"Base item with Id {id} could not be found")); }
public void Should_throw_error_when_no_restock_item_id() { var item = new ItemSourceBuilder().With(cr => cr.Id, 1).BuildAndSave(); var npc = new NPCBuilder().With(n => n.Id, 7).BuildAndSave(); var cmd = new UpdateRestockItem { AmountBeforeRestock = 1, BaseItemId = item.Id, AmountToRestockTo = 1, BotId = AIStatics.LindellaBotId }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo("RestockItemId must be set")); }
public void Should_throw_error_when_invalid_amount_to_restock() { var amount = -1; var item = new ItemSourceBuilder().With(cr => cr.Id, 1).BuildAndSave(); var cmd = new UpdateRestockItem { AmountBeforeRestock = amount, BaseItemId = item.Id, RestockItemId = restockItem.Id, AmountToRestockTo = 5, BotId = AIStatics.LindellaBotId }; Assert.That(() => Repository.Execute(cmd), Throws.TypeOf <DomainException>().With.Message.EqualTo("Minimum amount before restock must be 0")); }
public void Should_not_throw_error_when_amount_to_restock_is_zero() { var amount = 0; var item = new ItemSourceBuilder().With(cr => cr.Id, 215).BuildAndSave(); var cmd = new UpdateRestockItem { AmountBeforeRestock = amount, BaseItemId = item.Id, RestockItemId = restockItem.Id, AmountToRestockTo = 5, BotId = AIStatics.LindellaBotId }; Assert.That(() => Repository.Execute(cmd), Throws.Nothing); var editedRestockItem = DataContext.AsQueryable <RestockItem>().FirstOrDefault(cr => cr.Id == 13); Assert.That(editedRestockItem, Is.Not.Null); Assert.That(editedRestockItem.Id, Is.EqualTo(13)); }
public void Should_update_RestockItem() { var item = new ItemSourceBuilder().With(cr => cr.Id, 222).BuildAndSave(); var cmdEdit = new UpdateRestockItem { RestockItemId = 13, AmountBeforeRestock = 25, BaseItemId = item.Id, AmountToRestockTo = 50, BotId = AIStatics.LindellaBotId }; Assert.That(() => Repository.Execute(cmdEdit), Throws.Nothing); var editedRestockItem = DataContext.AsQueryable <RestockItem>().FirstOrDefault(cr => cr.Id == 13); Assert.That(editedRestockItem, Is.Not.Null); Assert.That(editedRestockItem.Id, Is.EqualTo(13)); Assert.That(editedRestockItem.AmountBeforeRestock, Is.EqualTo(25)); Assert.That(editedRestockItem.AmountToRestockTo, Is.EqualTo(50)); Assert.That(editedRestockItem.BaseItem.Id, Is.EqualTo(222)); Assert.That(editedRestockItem.BotId, Is.EqualTo(AIStatics.LindellaBotId)); }