示例#1
0
            private async Task <string> GetDataString(uint aToken)
            {
                ViewTokenDataSharedResponse dataString = await HttpClient.GetJsonAsync <ViewTokenDataSharedResponse>(ViewTokenDataSharedRequest.RouteFactory((int)aToken));

                string aDataString = dataString.TokenDataString;

                return(aDataString);
            }
        public async Task ShouldRetrieveToken4DataFromClient()
        {
            string uriString = ViewTokenDataSharedRequest.RouteFactory(4);

            ViewTokenDataSharedResponse clientResponse = await HttpClient.GetJsonAsync <ViewTokenDataSharedResponse>(uriString);

            clientResponse.TokenDataString.ShouldNotBe(null);
        }
示例#3
0
        public async Task ShouldGetTokenDataStringFromServerFeatures()
        { //
          // Arrange
            var TokenDataRequest = new ViewTokenDataSharedRequest()
            {
                TokenIdToGet = 5
            };
            // Act

            ViewTokenDataSharedResponse TokenDataResponse = await Mediator.Send(TokenDataRequest);

            TokenDataResponse.TokenDataString.ShouldBeOfType <string>();
        }
示例#4
0
            public override async Task <WebThreeState> Handle
            (
                ViewTokenDataAction aViewTokenDataRequest,
                CancellationToken aCancellationToken
            )
            {
                uint TokenId = aViewTokenDataRequest.TokenIdToGet;

                CurrentTokenData.TokenId = TokenId;

                ViewTokenDataSharedResponse DataString = await HttpClient.GetJsonAsync <ViewTokenDataSharedResponse>(ViewTokenDataSharedRequest.RouteFactory((int)TokenId));

                CurrentTokenData.Data          = DataString.TokenDataString;
                WebThreeState.CurrentTokenData = CurrentTokenData;

                return(WebThreeState);
            }
        //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);
        }