Example #1
0
        public IObservable <ActionBase.ActionEvaluation <SellCancellation> > SellCancellation(
            Address sellerAvatarAddress,
            Guid productId)
        {
            var action = new SellCancellation
            {
                productId           = productId,
                sellerAvatarAddress = sellerAvatarAddress,
            };

            ProcessAction(action);

            return(_renderer.EveryRender <SellCancellation>()
                   .Where(eval => eval.Action.Id.Equals(action.Id))
                   .Take(1)
                   .Last()
                   .ObserveOnMainThread()
                   .Timeout(ActionTimeout)
                   .DoOnError(e => HandleException(action.Id, e))); // Last() is for completion
        }
Example #2
0
        public void Execute()
        {
            var shopState = _initialState.GetShopState();

            Assert.Single(shopState.Products);

            var(_, shopItem) = shopState.Products.FirstOrDefault();
            Assert.NotNull(shopItem);

            var avatarState = _initialState.GetAvatarState(_avatarAddress);

            Assert.False(avatarState.inventory.TryGetNonFungibleItem(
                             shopItem.ItemUsable.ItemId,
                             out ItemUsable _));

            var sellCancellationAction = new SellCancellation
            {
                productId           = shopItem.ProductId,
                sellerAvatarAddress = _avatarAddress,
            };
            var nextState = sellCancellationAction.Execute(new ActionContext
            {
                BlockIndex     = 0,
                PreviousStates = _initialState,
                Random         = new ItemEnhancementTest.TestRandom(),
                Rehearsal      = false,
                Signer         = _agentAddress,
            });

            var nextShopState = nextState.GetShopState();

            Assert.Empty(nextShopState.Products);

            var nextAvatarState = nextState.GetAvatarState(_avatarAddress);

            Assert.True(nextAvatarState.inventory.TryGetNonFungibleItem(
                            shopItem.ItemUsable.ItemId,
                            out ItemUsable _));
        }