-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
199 additions
and
49 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
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,6 +1,6 @@ | ||
namespace EvoSC.Manialinks.Interfaces; | ||
|
||
public interface IManialinkTransaction | ||
public interface IManialinkTransaction : IManialinkOperations | ||
{ | ||
public Task CommitAsync(); | ||
} |
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
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
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
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
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
27 changes: 27 additions & 0 deletions
27
tests/Modules/LocalRecordsModule.Tests/Controllers/CommandsControllerTests.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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using EvoSC.Common.Interfaces.Models; | ||
using EvoSC.Manialinks.Interfaces; | ||
using EvoSC.Modules.Official.LocalRecordsModule.Controllers; | ||
using EvoSC.Testing.Controllers; | ||
using Moq; | ||
|
||
namespace LocalRecordsModule.Tests.Controllers; | ||
|
||
public class CommandsControllerTests : CommandInteractionControllerTestBase<CommandsController> | ||
{ | ||
private Mock<IOnlinePlayer> _actor = new(); | ||
private Mock<IManialinkManager> _manialinkManager = new(); | ||
|
||
public CommandsControllerTests() | ||
{ | ||
InitMock(_actor.Object, _manialinkManager); | ||
} | ||
|
||
[Fact] | ||
public async Task Reset_Locals_Is_Confirmed() | ||
{ | ||
await Controller.ResetLocalsAsync(); | ||
|
||
_manialinkManager.Verify(m => m.SendManialinkAsync(_actor.Object, "LocalRecordsModule.Dialogs.ConfirmResetDialog")); | ||
AuditEventBuilder.Verify(m => m.Cancel()); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
tests/Modules/LocalRecordsModule.Tests/Controllers/LocalRecordsManialinkControllerTests.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 |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using EvoSC.Common.Interfaces; | ||
using EvoSC.Common.Interfaces.Models; | ||
using EvoSC.Manialinks.Interfaces.Models; | ||
using EvoSC.Modules.Official.LocalRecordsModule.Controllers; | ||
using EvoSC.Modules.Official.LocalRecordsModule.Interfaces.Services; | ||
using EvoSC.Testing; | ||
using EvoSC.Testing.Controllers; | ||
using GbxRemoteNet.Interfaces; | ||
using Moq; | ||
|
||
namespace LocalRecordsModule.Tests.Controllers; | ||
|
||
public class LocalRecordsManialinkControllerTests : ManialinkControllerTestBase<LocalRecordsManialinkController> | ||
{ | ||
private readonly Mock<IManialinkActionContext> _manialinkActionContext = new(); | ||
private readonly Mock<IOnlinePlayer> _actor = new(); | ||
private readonly Mock<ILocalRecordsService> _localRecordsService = new(); | ||
private readonly (Mock<IServerClient> Server, Mock<IGbxRemoteClient> Remote) | ||
_server = Mocking.NewServerClientMock(); | ||
|
||
public LocalRecordsManialinkControllerTests() | ||
{ | ||
InitMock(_actor.Object, _manialinkActionContext.Object, _localRecordsService, _server.Server); | ||
} | ||
|
||
[Fact] | ||
public async Task Reset_Records_Confirmation_Resets_All_Records() | ||
{ | ||
await Controller.ConfirmResetAsync(true); | ||
|
||
ManialinkManager.Verify(m => m.HideManialinkAsync("LocalRecordsModule.Dialogs.ConfirmResetDialog")); | ||
_localRecordsService.Verify(m => m.ResetLocalRecordsAsync()); | ||
AuditEventBuilder.Verify(m => m.Success()); | ||
} | ||
|
||
[Fact] | ||
public async Task Reset_Records_Cancel_Does_Not_Resets_All_Records() | ||
{ | ||
await Controller.ConfirmResetAsync(false); | ||
|
||
ManialinkManager.Verify(m => m.HideManialinkAsync("LocalRecordsModule.Dialogs.ConfirmResetDialog")); | ||
_localRecordsService.Verify(m => m.ResetLocalRecordsAsync(), Times.Never); | ||
AuditEventBuilder.Verify(m => m.Success(), Times.Never); | ||
AuditEventBuilder.Verify(m => m.Error(), Times.Never); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
tests/Modules/LocalRecordsModule.Tests/Controllers/WidgetUpdateControllerTests.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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
using EvoSC.Common.Interfaces.Models; | ||
using EvoSC.Common.Interfaces.Models.Enums; | ||
using EvoSC.Common.Interfaces.Services; | ||
using EvoSC.Common.Models.Maps; | ||
using EvoSC.Common.Models.Players; | ||
using EvoSC.Modules.Official.LocalRecordsModule.Controllers; | ||
using EvoSC.Modules.Official.LocalRecordsModule.Interfaces.Services; | ||
using EvoSC.Modules.Official.PlayerRecords.Database.Models; | ||
using EvoSC.Modules.Official.PlayerRecords.Events; | ||
using EvoSC.Testing.Controllers; | ||
using GbxRemoteNet.Events; | ||
using Moq; | ||
|
||
namespace LocalRecordsModule.Tests.Controllers; | ||
|
||
public class WidgetUpdateControllerTests : EventControllerTestBase<WidgetUpdateController> | ||
{ | ||
private readonly Mock<ILocalRecordsService> _localRecordsService = new(); | ||
private readonly Mock<IPlayerManagerService> _playerManagerService = new(); | ||
|
||
public WidgetUpdateControllerTests() | ||
{ | ||
InitMock(_localRecordsService, _playerManagerService); | ||
} | ||
|
||
[Fact] | ||
public async Task Widget_Shown_For_Player_On_Join() | ||
{ | ||
var player = new OnlinePlayer | ||
{ | ||
Id = 1, | ||
AccountId = "a467a996-eba5-44bf-9e2b-8543b50f39ae", | ||
NickName = "snixtho", | ||
UbisoftName = "snixtho", | ||
State = PlayerState.Playing | ||
}; | ||
|
||
_playerManagerService.Setup(m => m.GetOnlinePlayerAsync("a467a996-eba5-44bf-9e2b-8543b50f39ae")) | ||
.ReturnsAsync(player); | ||
|
||
await Controller.OnPlayerConnectAsync(null, new PlayerConnectGbxEventArgs { Login = "pGepluulRL-eK4VDtQ85rg" }); | ||
|
||
_localRecordsService.Verify(m => m.ShowWidgetAsync(player)); | ||
} | ||
|
||
[Fact] | ||
public async Task Widget_Is_Updated_When_New_Map_Starts() | ||
{ | ||
await Controller.OnBeginMapAsync(null, new MapGbxEventArgs()); | ||
|
||
_localRecordsService.Verify(m => m.ShowWidgetToAllAsync()); | ||
} | ||
|
||
[Fact] | ||
public async Task Local_Records_Are_Updated_When_Player_Gets_Pb() | ||
{ | ||
var record = new DbPlayerRecord(); | ||
var player = new Player(); | ||
var map = new Map(); | ||
|
||
var args = new PbRecordUpdateEventArgs | ||
{ | ||
Player = player, Map = map, Record = record, Status = RecordUpdateStatus.New | ||
}; | ||
|
||
await Controller.OnPbAsync(null, args); | ||
|
||
_localRecordsService.Verify(m => m.UpdatePbAsync(record)); | ||
} | ||
} |
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.