-
Notifications
You must be signed in to change notification settings - Fork 34
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 #545 from sguoo/test/collection-test
Add Collection Test
- Loading branch information
Showing
6 changed files
with
59 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
11 changes: 11 additions & 0 deletions
11
...ests/QueryTests/CollectionTest.GraphQL_Query_Collection_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,11 @@ | ||
{ | ||
"data": { | ||
"collection": { | ||
"ids": [ | ||
1, | ||
2, | ||
3 | ||
] | ||
} | ||
} | ||
} |
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,38 @@ | ||
using Mimir.MongoDB.Repositories; | ||
using Moq; | ||
using Lib9c.Models.States; | ||
using Libplanet.Crypto; | ||
using Mimir.MongoDB.Bson; | ||
|
||
namespace Mimir.Tests.QueryTests; | ||
|
||
public class CollectionTest | ||
{ | ||
[Fact] | ||
public async Task GraphQL_Query_Collection_Returns_CorrectValue() | ||
{ | ||
var address = new Address("0x0000000001000000000200000000030000000004"); | ||
var state = new CollectionState | ||
{ | ||
Ids = new SortedSet<int>(new[] { 1, 2, 3 }) | ||
}; | ||
var mockRepo = new Mock<ICollectionRepository>(); | ||
mockRepo | ||
.Setup(repo => repo.GetByAddressAsync(It.IsAny<Address>())) | ||
.ReturnsAsync(new CollectionDocument(1, address, state)); | ||
var serviceProvider = TestServices.Builder | ||
.With(mockRepo.Object) | ||
.Build(); | ||
var query = $$""" | ||
query { | ||
collection(address: "{{address}}") { | ||
ids | ||
} | ||
} | ||
"""; | ||
|
||
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