diff --git a/NineChronicles.Headless.Tests/GraphTypes/DelegatorTypeTest.cs b/NineChronicles.Headless.Tests/GraphTypes/DelegatorTypeTest.cs new file mode 100644 index 000000000..486303f27 --- /dev/null +++ b/NineChronicles.Headless.Tests/GraphTypes/DelegatorTypeTest.cs @@ -0,0 +1,45 @@ +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Numerics; +using System.Threading.Tasks; +using GraphQL.Execution; +using Lib9c; +using Libplanet.Types.Tx; +using Nekoyume.ValidatorDelegation; +using NineChronicles.Headless.GraphTypes; +using Xunit; +using Xunit.Abstractions; + +namespace NineChronicles.Headless.Tests.GraphTypes +{ + public class DelegatorTypeTest + { + [Fact] + public async Task ExecuteQuery() + { + var lastDistributeHeight = 1L; + var share = new BigInteger(1000000000000000000) * 10; + var fav = Currencies.GuildGold * 10; + + var result = await GraphQLTestUtils.ExecuteQueryAsync( + "{ lastDistributeHeight share fav { currency quantity } }", + source: new DelegatorType + { + LastDistributeHeight = lastDistributeHeight, + Share = share, + Fav = fav, + } + ); + + // Then + var data = (Dictionary)((ExecutionNode)result.Data!).ToValue()!; + + Assert.Equal(lastDistributeHeight, data["lastDistributeHeight"]); + Assert.Equal(share.ToString("N0"), data["share"]); + + var favResult = (Dictionary)data["fav"]; + Assert.Equal(fav.Currency.Ticker, favResult["currency"]); + Assert.Equal(fav.GetQuantityString(minorUnit: true), favResult["quantity"]); + } + } +}