public void ExecuteThrowNotEnoughMaterialException()
        {
            var row = _tableSheets.ConsumableItemRecipeSheet.Values.First();

            const int requiredStage = GameConfig.RequireClearedStageLevel.CombinationConsumableAction;

            for (var i = 1; i < requiredStage + 1; i++)
            {
                _avatarState.worldInformation.ClearStage(1, i, 0, _tableSheets.WorldSheet, _tableSheets.WorldUnlockSheet);
            }

            _initialState = _initialState
                            .SetState(_avatarAddress, _avatarState.Serialize())
                            .SetState(_slotAddress, new CombinationSlotState(_slotAddress, requiredStage).Serialize());

            var action = new CombinationConsumable0()
            {
                AvatarAddress = _avatarAddress,
                recipeId      = row.Id,
                slotIndex     = 0,
            };

            Assert.Throws <NotEnoughMaterialException>(() => action.Execute(new ActionContext()
            {
                PreviousStates = _initialState,
                Signer         = _agentAddress,
                BlockIndex     = 1,
                Random         = _random,
            })
                                                       );
        }
        public void Execute()
        {
            var row = _tableSheets.ConsumableItemRecipeSheet.Values.First();

            foreach (var materialInfo in row.Materials)
            {
                var materialRow = _tableSheets.MaterialItemSheet[materialInfo.Id];
                var material    = ItemFactory.CreateItem(materialRow, _random);
                _avatarState.inventory.AddItem2(material, count: materialInfo.Count);
            }

            const int requiredStage = GameConfig.RequireClearedStageLevel.CombinationConsumableAction;

            for (var i = 1; i < requiredStage + 1; i++)
            {
                _avatarState.worldInformation.ClearStage(1, i, 0, _tableSheets.WorldSheet, _tableSheets.WorldUnlockSheet);
            }

            _initialState = _initialState
                            .SetState(_avatarAddress, _avatarState.Serialize())
                            .SetState(_slotAddress, new CombinationSlotState(_slotAddress, requiredStage).Serialize());

            var action = new CombinationConsumable0()
            {
                AvatarAddress = _avatarAddress,
                recipeId      = row.Id,
                slotIndex     = 0,
            };

            var nextState = action.Execute(new ActionContext()
            {
                PreviousStates = _initialState,
                Signer         = _agentAddress,
                BlockIndex     = 1,
                Random         = _random,
            });

            var slotState = nextState.GetCombinationSlotState(_avatarAddress, 0);

            Assert.NotNull(slotState.Result);

            var consumable = (Consumable)slotState.Result.itemUsable;

            Assert.NotNull(consumable);
        }
        public void ExecuteThrowFailedLoadStateException()
        {
            var action = new CombinationConsumable0()
            {
                AvatarAddress = _avatarAddress,
                recipeId      = 1,
                slotIndex     = 0,
            };

            Assert.Throws <FailedLoadStateException>(() => action.Execute(new ActionContext()
            {
                PreviousStates = new State(),
                Signer         = _agentAddress,
                BlockIndex     = 1,
                Random         = _random,
            })
                                                     );
        }
        public void ExecuteThrowNotEnoughClearedStageLevelException()
        {
            _initialState = _initialState
                            .SetState(_slotAddress, new CombinationSlotState(_slotAddress, 0).Serialize());

            var action = new CombinationConsumable0()
            {
                AvatarAddress = _avatarAddress,
                recipeId      = 1,
                slotIndex     = 0,
            };

            Assert.Throws <NotEnoughClearedStageLevelException>(() => action.Execute(new ActionContext()
            {
                PreviousStates = _initialState,
                Signer         = _agentAddress,
                BlockIndex     = 1,
                Random         = _random,
            })
                                                                );
        }