public IObservable <ActionBase.ActionEvaluation <Sell3> > Sell(INonFungibleItem item, FungibleAssetValue price) { var avatarAddress = States.Instance.CurrentAvatarState.address; // NOTE: 장착했는지 안 했는지에 상관없이 해제 플래그를 걸어 둔다. LocalLayerModifier.SetItemEquip(avatarAddress, item.ItemId, false, false); var action = new Sell3 { sellerAvatarAddress = avatarAddress, itemId = item.ItemId, price = price }; ProcessAction(action); return(_renderer.EveryRender <Sell3>() .Where(eval => eval.Action.Id.Equals(action.Id)) .Take(1) .Last() .ObserveOnMainThread() .Timeout(ActionTimeout) .DoOnError(e => HandleException(action.Id, e))); // Last() is for completion }
public void Execute() { var shopState = _initialState.GetShopState(); Assert.Empty(shopState.Products); var avatarState = _initialState.GetAvatarState(_avatarAddress); Assert.Single(avatarState.inventory.Equipments); var equipment = avatarState.inventory.Equipments.FirstOrDefault(); Assert.NotNull(equipment); var consumable = avatarState.inventory.Consumables.FirstOrDefault(); Assert.NotNull(equipment); var costume = avatarState.inventory.Costumes.FirstOrDefault(); Assert.NotNull(costume); var items = new INonFungibleItem[] { equipment, consumable, costume }; var previousStates = _initialState; var currencyState = previousStates.GetGoldCurrency(); var price = new FungibleAssetValue(currencyState, ProductPrice, 0); var productCount = 0; var random = new TestRandom(); foreach (var nonFungibleItem in items) { var sellAction = new Sell3 { itemId = nonFungibleItem.ItemId, price = price, sellerAvatarAddress = _avatarAddress, }; var nextState = sellAction.Execute(new ActionContext { BlockIndex = 0, PreviousStates = previousStates, Rehearsal = false, Signer = _agentAddress, Random = random, }); productCount++; var nextAvatarState = nextState.GetAvatarState(_avatarAddress); Assert.Empty(nextAvatarState.inventory.Equipments); var nextShopState = nextState.GetShopState(); Assert.Equal(productCount, nextShopState.Products.Count); var products = nextShopState.Products.Values; Assert.NotNull(products); var shopItem = nonFungibleItem is Costume? products.First(x => x.Costume != null) : products.First(x => x.ItemUsable != null); Assert.Equal(price, shopItem.Price); Assert.Equal(_agentAddress, shopItem.SellerAgentAddress); Assert.Equal(_avatarAddress, shopItem.SellerAvatarAddress); previousStates = nextState; } }