Esempio n. 1
0
        public void Execute()
        {
            var dailyRewardAction = new DailyReward3
            {
                avatarAddress = _avatarAddress,
            };
            var nextState = dailyRewardAction.Execute(new ActionContext
            {
                BlockIndex     = 0,
                PreviousStates = _initialState,
                Random         = new TestRandom(),
                Rehearsal      = false,
                Signer         = _agentAddress,
            });

            var gameConfigState = nextState.GetGameConfigState();
            var nextAvatarState = nextState.GetAvatarState(_avatarAddress);

            Assert.Equal(gameConfigState.ActionPointMax, nextAvatarState.actionPoint);
            Assert.Single(nextAvatarState.mailBox);
            var mail       = nextAvatarState.mailBox.First();
            var rewardMail = mail as DailyRewardMail;

            Assert.NotNull(rewardMail);
            var rewardResult = rewardMail.attachment as DailyReward2.DailyRewardResult;

            Assert.NotNull(rewardResult);
            Assert.Single(rewardResult.materials);
            var material = rewardResult.materials.First();

            Assert.Equal(400000, material.Key.Id);
            Assert.Equal(10, material.Value);
        }
Esempio n. 2
0
        public void ExecuteThrowFailedLoadStateException()
        {
            var action = new DailyReward3
            {
                avatarAddress = _avatarAddress,
            };

            Assert.Throws <FailedLoadStateException>(() => action.Execute(new ActionContext()
            {
                PreviousStates = new State(),
                Signer         = _agentAddress,
                BlockIndex     = 0,
            })
                                                     );
        }