public async Task SharedShouldGetTokenNftType()
        {
            // Arrange
            var getNftSharedRequest = new GetTokenNftTypeSharedRequest {
                TokenId = 3
            };

            // Act
            GetTokenNftTypeSharedResponse response = await Mediator.Send(getNftSharedRequest);

            //Assert
            response.NftType.ShouldBe((uint)4);
        }
Example #2
0
            public override async Task <WebThreeState> Handle
            (
                FetchTokenNftTypeAction aFetchTokenNftTypeClientRequest,
                CancellationToken aCancellationToken
            )
            {
                int TokenId = aFetchTokenNftTypeClientRequest.TokenId;

                string requestUri = GetTokenNftTypeSharedRequest.RouteFactory(TokenId);

                GetTokenNftTypeSharedResponse type = await HttpClient.GetJsonAsync <GetTokenNftTypeSharedResponse>(requestUri);

                WebThreeState.CurrentTokenNftType = type.NftType;

                return(WebThreeState);
            }
Example #3
0
            private async Task <NftTemplate> GetNft(uint aToken)
            { // TokenNftTypeData Should already have the data in state so no need to make a service call
                GetTokenNftTypeSharedResponse nftContainer = await HttpClient.GetJsonAsync <GetTokenNftTypeSharedResponse>(GetTokenNftTypeSharedRequest.RouteFactory((int)aToken));

                NftTemplate template = WebThreeState.TemplateDataList.Find(aNft => aNft.NftId == nftContainer.NftType);

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