public async Task ShouldRetrieveTokenBalanceFromClient() { string uriString = BalanceOfSharedRequest.RouteFactory(3); BalanceOfSharedResponse clientResponse = await HttpClient.GetJsonAsync <BalanceOfSharedResponse>(uriString); clientResponse.ShouldBeOfType <BalanceOfSharedResponse>(); clientResponse.Balance.ShouldNotBe(0); clientResponse.Balance.ShouldBe(1); }
private async Task <int> GetBalance(uint aToken) { BalanceOfSharedResponse aBalanceContainer = await HttpClient.GetJsonAsync <BalanceOfSharedResponse>(BalanceOfSharedRequest.RouteFactory((int)aToken)); return(aBalanceContainer.Balance); }
//List<NftTemplate> TemplateDataList => WebThreeState.TemplateDataList; public async Task ShouldBuildTokenList() { WebThreeState webThree = await Mediator.Send(new GetNftTypesClientFeaturesAction()); GetAllOwnedTokensSharedResponse aTokenList = await HttpClient.GetJsonAsync <GetAllOwnedTokensSharedResponse>(GetAllOwnedTokensSharedRequest.Route); aTokenList.TokenIdList.Count.ShouldBeGreaterThan(3); aTokenList.TokenIdList.Contains(3).ShouldBe(true); aTokenList.TokenIdList.Contains(4).ShouldBe(true); aTokenList.TokenIdList.Contains(5).ShouldBe(true); foreach (uint token in aTokenList.TokenIdList) { // TokenId var ownedToken = new TokenBase() { TokenId = token }; // TokenNFtTypeId string getNftTypeUri = GetTokenNftTypeSharedRequest.RouteFactory((int)token); WebThreeState NftTypeContainer = await Mediator.Send(new FetchTokenNftTypeAction() { TokenId = (int)ownedToken.TokenId }); // TokenNftTypeData Should already have the data in state so no need to make a service call NftTemplate nftType = webThree.TemplateDataList.Find(nft => nft.NftId == NftTypeContainer.CurrentTokenNftType); ownedToken.TemplateData = nftType; // Token Balance BalanceOfSharedResponse BalanceContainer = await HttpClient.GetJsonAsync <BalanceOfSharedResponse>(BalanceOfSharedRequest.RouteFactory((int)token)); ownedToken.Balance = BalanceContainer.Balance; // Token ImmutableData (Data) ownedToken.TemplateData.ShouldBeOfType <NftTemplate>(); ViewTokenDataSharedResponse DataString = await HttpClient.GetJsonAsync <ViewTokenDataSharedResponse>(ViewTokenDataSharedRequest.RouteFactory((int)token)); DataString.TokenDataString.ShouldNotBe(null); if (token == 3) { byte[] serializedImmutableData = Convert.FromBase64String(DataString.TokenDataString); // need to figure out a way to get the type occording to the nftId ImmutableData DeserializedObject = Serializer.Deserialize <ImmutableData>(serializedImmutableData, options); // options == 0 ownedToken.ImmDataObj = DeserializedObject; // Add to StateList TokenDataList.Add(ownedToken); } else { ownedToken.Data = DataString.TokenDataString; TokenDataList.Add(ownedToken); } } TokenDataList.Count.ShouldBe(3); }