-
Notifications
You must be signed in to change notification settings - Fork 1
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 #43 from Atralupus/feat/worker
Implement worker
- Loading branch information
Showing
24 changed files
with
2,135 additions
and
127 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"strawberryshake.tools": { | ||
"version": "14.3.0", | ||
"commands": [ | ||
"dotnet-graphql" | ||
], | ||
"rollForward": false | ||
} | ||
} | ||
} |
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,6 @@ | ||
[submodule "NineChronicles.RPC.Shared"] | ||
path = NineChronicles.RPC.Shared | ||
url = [email protected]:planetarium/NineChronicles.RPC.Shared.git | ||
[submodule "Lib9c"] | ||
path = Lib9c | ||
url = [email protected]:planetarium/lib9c.git |
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
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
192 changes: 96 additions & 96 deletions
192
ArenaService.Tests/Controllers/BattleControllerTests.cs
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 |
---|---|---|
@@ -1,105 +1,105 @@ | ||
using System.Security.Claims; | ||
using ArenaService.Controllers; | ||
using ArenaService.Models; | ||
using ArenaService.Repositories; | ||
using ArenaService.Tests.Utils; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.AspNetCore.Http.HttpResults; | ||
using Microsoft.AspNetCore.Mvc; | ||
using Moq; | ||
// using System.Security.Claims; | ||
// using ArenaService.Controllers; | ||
// using ArenaService.Models; | ||
// using ArenaService.Repositories; | ||
// using ArenaService.Tests.Utils; | ||
// using Microsoft.AspNetCore.Http; | ||
// using Microsoft.AspNetCore.Http.HttpResults; | ||
// using Microsoft.AspNetCore.Mvc; | ||
// using Moq; | ||
|
||
namespace ArenaService.Tests.Controllers; | ||
// namespace ArenaService.Tests.Controllers; | ||
|
||
public class BattleControllerTests | ||
{ | ||
private readonly BattleController _controller; | ||
private Mock<IAvailableOpponentRepository> _availableOpponentRepoMock; | ||
private Mock<IParticipantRepository> _participantRepoMock; | ||
private Mock<IBattleLogRepository> _battleLogRepoMock; | ||
// public class BattleControllerTests | ||
// { | ||
// private readonly BattleController _controller; | ||
// private Mock<IAvailableOpponentRepository> _availableOpponentRepoMock; | ||
// private Mock<IParticipantRepository> _participantRepoMock; | ||
// private Mock<IBattleLogRepository> _battleLogRepoMock; | ||
|
||
public BattleControllerTests() | ||
{ | ||
var availableOpponentRepoMock = new Mock<IAvailableOpponentRepository>(); | ||
_availableOpponentRepoMock = availableOpponentRepoMock; | ||
var participantRepoMock = new Mock<IParticipantRepository>(); | ||
_participantRepoMock = participantRepoMock; | ||
var battleLogRepoMock = new Mock<IBattleLogRepository>(); | ||
_battleLogRepoMock = battleLogRepoMock; | ||
_controller = new BattleController( | ||
_availableOpponentRepoMock.Object, | ||
_participantRepoMock.Object, | ||
_battleLogRepoMock.Object | ||
); | ||
} | ||
// public BattleControllerTests() | ||
// { | ||
// var availableOpponentRepoMock = new Mock<IAvailableOpponentRepository>(); | ||
// _availableOpponentRepoMock = availableOpponentRepoMock; | ||
// var participantRepoMock = new Mock<IParticipantRepository>(); | ||
// _participantRepoMock = participantRepoMock; | ||
// var battleLogRepoMock = new Mock<IBattleLogRepository>(); | ||
// _battleLogRepoMock = battleLogRepoMock; | ||
// _controller = new BattleController( | ||
// _availableOpponentRepoMock.Object, | ||
// _participantRepoMock.Object, | ||
// _battleLogRepoMock.Object | ||
// ); | ||
// } | ||
|
||
[Fact] | ||
public async Task GetBattleToken_WithValidHeader_ReturnsOk() | ||
{ | ||
var avatarAddress = "DDF1472fD5a79B8F46C28e7643eDEF045e36BD3d"; | ||
ControllerTestUtils.ConfigureMockHttpContextWithAuth(_controller, avatarAddress); | ||
// [Fact] | ||
// public async Task GetBattleToken_WithValidHeader_ReturnsOk() | ||
// { | ||
// var avatarAddress = "DDF1472fD5a79B8F46C28e7643eDEF045e36BD3d"; | ||
// ControllerTestUtils.ConfigureMockHttpContextWithAuth(_controller, avatarAddress); | ||
|
||
_participantRepoMock | ||
.Setup(repo => repo.GetParticipantByAvatarAddressAsync(1, avatarAddress)) | ||
.ReturnsAsync( | ||
new Participant | ||
{ | ||
Id = 1, | ||
AvatarAddress = avatarAddress, | ||
NameWithHash = "test", | ||
PortraitId = 1 | ||
} | ||
); | ||
// _participantRepoMock | ||
// .Setup(repo => repo.GetParticipantByAvatarAddressAsync(1, avatarAddress)) | ||
// .ReturnsAsync( | ||
// new Participant | ||
// { | ||
// Id = 1, | ||
// AvatarAddress = avatarAddress, | ||
// NameWithHash = "test", | ||
// PortraitId = 1 | ||
// } | ||
// ); | ||
|
||
_availableOpponentRepoMock | ||
.Setup(repo => repo.GetAvailableOpponents(1)) | ||
.ReturnsAsync( | ||
[ | ||
new AvailableOpponent | ||
{ | ||
Id = 1, | ||
ParticipantId = 1, | ||
OpponentId = 2, | ||
Opponent = new Participant | ||
{ | ||
Id = 2, | ||
AvatarAddress = "test", | ||
NameWithHash = "opponent1", | ||
PortraitId = 1 | ||
}, | ||
RefillBlockIndex = 1 | ||
}, | ||
new AvailableOpponent | ||
{ | ||
Id = 2, | ||
ParticipantId = 1, | ||
OpponentId = 3, | ||
Opponent = new Participant | ||
{ | ||
Id = 3, | ||
AvatarAddress = "test", | ||
NameWithHash = "opponent2", | ||
PortraitId = 1 | ||
}, | ||
RefillBlockIndex = 1 | ||
} | ||
] | ||
); | ||
// _availableOpponentRepoMock | ||
// .Setup(repo => repo.GetAvailableOpponents(1)) | ||
// .ReturnsAsync( | ||
// [ | ||
// new AvailableOpponent | ||
// { | ||
// Id = 1, | ||
// ParticipantId = 1, | ||
// OpponentId = 2, | ||
// Opponent = new Participant | ||
// { | ||
// Id = 2, | ||
// AvatarAddress = "test", | ||
// NameWithHash = "opponent1", | ||
// PortraitId = 1 | ||
// }, | ||
// RefillBlockIndex = 1 | ||
// }, | ||
// new AvailableOpponent | ||
// { | ||
// Id = 2, | ||
// ParticipantId = 1, | ||
// OpponentId = 3, | ||
// Opponent = new Participant | ||
// { | ||
// Id = 3, | ||
// AvatarAddress = "test", | ||
// NameWithHash = "opponent2", | ||
// PortraitId = 1 | ||
// }, | ||
// RefillBlockIndex = 1 | ||
// } | ||
// ] | ||
// ); | ||
|
||
_battleLogRepoMock | ||
.Setup(repo => repo.AddBattleLogAsync(1, 1, 1, "token")) | ||
.ReturnsAsync( | ||
new BattleLog | ||
{ | ||
Id = 1, | ||
ParticipantId = 1, | ||
OpponentId = 1, | ||
SeasonId = 1, | ||
Token = "token" | ||
} | ||
); | ||
// _battleLogRepoMock | ||
// .Setup(repo => repo.AddBattleLogAsync(1, 1, 1, "token")) | ||
// .ReturnsAsync( | ||
// new BattleLog | ||
// { | ||
// Id = 1, | ||
// ParticipantId = 1, | ||
// OpponentId = 1, | ||
// SeasonId = 1, | ||
// Token = "token" | ||
// } | ||
// ); | ||
|
||
var result = await _controller.CreateBattleToken(1, 1); | ||
// var result = await _controller.CreateBattleToken(1, 1); | ||
|
||
var okResult = Assert.IsType<Ok<string>>(result.Result); | ||
} | ||
} | ||
// var okResult = Assert.IsType<Ok<string>>(result.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
Oops, something went wrong.