-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #562 from JongHyun070105/jonghyun/test
- Loading branch information
Showing
6 changed files
with
111 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...sts/WorldInformationTest.GraphQL_Query_WorldInformation_Returns_CorrectValue.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"data": { | ||
"worldInformation": { | ||
"worldDictionary": [ | ||
{ | ||
"key": 1, | ||
"value": { | ||
"id": 1, | ||
"isStageCleared": true, | ||
"isUnlocked": true, | ||
"name": "kim", | ||
"stageBegin": 2, | ||
"stageClearedBlockIndex": 1, | ||
"stageClearedId": 2, | ||
"stageEnd": 3, | ||
"unlockedBlockIndex": 2 | ||
} | ||
} | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
using Bencodex.Types; | ||
using Lib9c.Models.States; | ||
using Lib9c.Models.WorldInformation; | ||
using Libplanet.Crypto; | ||
using Mimir.MongoDB.Bson; | ||
using Mimir.MongoDB.Repositories; | ||
using Mimir.Tests; | ||
using Moq; | ||
using Nekoyume.Model.State; | ||
|
||
public class WorldInformationTest | ||
{ | ||
[Fact] | ||
public async Task GraphQL_Query_WorldInformation_Returns_CorrectValue() | ||
{ | ||
var address = new Address("0x0000000000000000000000000000000000000000"); | ||
|
||
var mockRepo = new Mock<IWorldInformationRepository>(); | ||
mockRepo | ||
.Setup(repo => repo.GetByAddressAsync(It.IsAny<Address>())) | ||
.ReturnsAsync(new WorldInformationDocument( | ||
0, | ||
default, | ||
new WorldInformationState() | ||
{ | ||
WorldDictionary = new Dictionary<int, World>() | ||
{ | ||
{ | ||
1, | ||
new World(new Dictionary(new Dictionary<IKey, IValue> | ||
{ | ||
[(Text)"Id"] = 1.Serialize(), | ||
[(Text)"Name"] = "kim".Serialize(), | ||
[(Text)"StageBegin"] = 2.Serialize(), | ||
[(Text)"StageEnd"] = 3.Serialize(), | ||
[(Text)"UnlockedBlockIndex"] = 2.Serialize(), | ||
[(Text)"StageClearedBlockIndex"] = 1.Serialize(), | ||
[(Text)"StageClearedId"] = 2.Serialize(), | ||
})) | ||
} | ||
} | ||
} | ||
)); | ||
|
||
var serviceProvider = TestServices.Builder | ||
.With(mockRepo.Object) | ||
.Build(); | ||
|
||
var query = $$""" | ||
query { | ||
worldInformation(address: "{{address}}") { | ||
worldDictionary { | ||
key | ||
value { | ||
id | ||
isStageCleared | ||
isUnlocked | ||
name | ||
stageBegin | ||
stageClearedBlockIndex | ||
stageClearedId | ||
stageEnd | ||
unlockedBlockIndex | ||
} | ||
} | ||
} | ||
} | ||
"""; | ||
|
||
var result = await TestServices.ExecuteRequestAsync(serviceProvider, b => b.SetDocument(query)); | ||
|
||
await Verify(result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters