diff --git a/.Lib9c.Tests/Action/AdventureBoss/SweepAdventureBossTest.cs b/.Lib9c.Tests/Action/AdventureBoss/SweepAdventureBossTest.cs index 3021ca8bf8..f6295e64f9 100644 --- a/.Lib9c.Tests/Action/AdventureBoss/SweepAdventureBossTest.cs +++ b/.Lib9c.Tests/Action/AdventureBoss/SweepAdventureBossTest.cs @@ -99,7 +99,7 @@ public static IEnumerable GetExecuteMemberData() }; yield return new object[] { - 1, 0, 0, typeof(NotEnoughMaterialException), null, + 1, 1, 1, typeof(NotEnoughMaterialException), null, }; yield return new object[] { diff --git a/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs index 1fe7a4ab74..06dd895202 100644 --- a/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs +++ b/.Lib9c.Tests/Action/Summon/AuraSummonTest.cs @@ -134,7 +134,7 @@ public void CumulativeRatio(string version, int groupId) 9, 800201, 9, - 0, + 2, new[] { 10610000, 10610000, 10610000, 10610000, 10610000, 10610000, 10620000, 10620000, 10620000, }, null )] @@ -144,7 +144,7 @@ public void CumulativeRatio(string version, int groupId) 9, 600201, 9, - 0, + 1, new[] { 10620001, 10620001, 10620001, 10620001, 10620001, 10630001, 10630001, 10630001, 10630001, }, null )] @@ -155,7 +155,7 @@ public void CumulativeRatio(string version, int groupId) 10, 800201, 10, - 0, + 1, new[] { 10610000, 10610000, 10610000, 10610000, 10610000, 10610000, 10610000, 10610000, 10620000, 10620000, 10620000, }, null )] @@ -165,15 +165,15 @@ public void CumulativeRatio(string version, int groupId) 10, 600201, 10, - 0, + 2, new[] { 10620001, 10620001, 10620001, 10620001, 10620001, 10620001, 10630001, 10620001, 10630001, 10630001, 10630001, }, null )] // fail by invalid group - [InlineData("V1", 100003, 1, null, 0, 0, new int[] { }, typeof(RowNotInTableException))] + [InlineData("V1", 100003, 1, null, 0, 1, new int[] { }, typeof(RowNotInTableException))] // fail by not enough material - [InlineData("V1", 10001, 1, 800201, 0, 0, new int[] { }, typeof(NotEnoughMaterialException))] - [InlineData("V1", 10001, 2, 800201, 0, 0, new int[] { }, typeof(NotEnoughMaterialException))] + [InlineData("V1", 10001, 1, 800201, 0, 2, new int[] { }, typeof(NotEnoughMaterialException))] + [InlineData("V1", 10001, 2, 800201, 0, 1, new int[] { }, typeof(NotEnoughMaterialException))] // Fail by exceeding summon limit [InlineData("V1", 10001, 11, 800201, 22, 1, new int[] { }, typeof(InvalidSummonCountException))] // 15 recipes diff --git a/.Lib9c.Tests/Action/Summon/RuneSummonTest.cs b/.Lib9c.Tests/Action/Summon/RuneSummonTest.cs index 08ec4c6e4f..21d4aa28f5 100644 --- a/.Lib9c.Tests/Action/Summon/RuneSummonTest.cs +++ b/.Lib9c.Tests/Action/Summon/RuneSummonTest.cs @@ -208,7 +208,7 @@ private class ExecuteMemeber : IEnumerable 9, 600201, 9, - 0, + 2, null, }, // Ten plus one @@ -218,7 +218,7 @@ private class ExecuteMemeber : IEnumerable 10, 600201, 10, - 0, + 1, null, }, // fail by invalid group diff --git a/.Lib9c.Tests/Model/Item/InventoryTest.cs b/.Lib9c.Tests/Model/Item/InventoryTest.cs index acc3d25385..3204e7bafa 100644 --- a/.Lib9c.Tests/Model/Item/InventoryTest.cs +++ b/.Lib9c.Tests/Model/Item/InventoryTest.cs @@ -4,6 +4,7 @@ using System.Collections.Generic; using System.Linq; using Lib9c.Tests.Action; + using Nekoyume.Action; using Nekoyume.Model.Item; using Nekoyume.TableData; using Xunit; @@ -34,6 +35,19 @@ public void Serialize() } // Add + [Fact] + public void AddItemZero() + { + var item = GetFirstConsumable(); + var inventory = new Inventory(); + Assert.Empty(inventory.Items); + + Assert.Throws(() => + { + inventory.AddItem(item, 0); + }); + } + [Fact] public Inventory AddItem_Consumable() { diff --git a/Lib9c/Model/Item/Inventory.cs b/Lib9c/Model/Item/Inventory.cs index d134342cf4..4eb4e9b9bc 100644 --- a/Lib9c/Model/Item/Inventory.cs +++ b/Lib9c/Model/Item/Inventory.cs @@ -175,6 +175,11 @@ public object Clone() public KeyValuePair AddItem(ItemBase itemBase, int count = 1, ILock iLock = null) { + if(count == 0) + { + throw new InvalidItemCountException(); + } + switch (itemBase.ItemType) { case ItemType.Consumable: