-
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 #555 from pty0735/feat/my-work
Add integration Test for Pet Metadata Query #548
- Loading branch information
Showing
6 changed files
with
66 additions
and
3 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
9 changes: 9 additions & 0 deletions
9
Mimir.Tests/QueryTests/PetTest.GraphQL_Query_Pet_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,9 @@ | ||
{ | ||
"data": { | ||
"pet": { | ||
"level": 1, | ||
"petId": 1, | ||
"unlockedBlockIndex": 0 | ||
} | ||
} | ||
} |
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,50 @@ | ||
using Lib9c.Models.States; | ||
using Libplanet.Crypto; | ||
using Mimir.MongoDB.Bson; | ||
using Mimir.MongoDB.Repositories; | ||
using Mimir.Tests; | ||
using Moq; | ||
|
||
public class PetTest | ||
{ | ||
[Fact] | ||
public async Task GraphQL_Query_Pet_Returns_CorrectValue() | ||
{ | ||
|
||
// process mokking | ||
var address = new Address(); | ||
var mockRepo = new Mock<IPetRepository>(); | ||
mockRepo | ||
.Setup(repo => repo.GetByAvatarAddressAsync(It.IsAny<Address>())) | ||
.ReturnsAsync(new PetStateDocument( | ||
1, | ||
new Address(), | ||
new Address(), | ||
new PetState() { | ||
PetId = 1, | ||
Level = 1, | ||
UnlockedBlockIndex = default | ||
} | ||
)); | ||
|
||
var serviceProvider = TestServices.Builder | ||
.With(mockRepo.Object) | ||
.Build(); | ||
|
||
var query = $$""" | ||
query { | ||
pet(avatarAddress: "{{address}}") { | ||
level | ||
petId | ||
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