diff --git a/src/Modules/LocalRecordsModule/Interfaces/Database/ILocalRecordRepository.cs b/src/Modules/LocalRecordsModule/Interfaces/Database/ILocalRecordRepository.cs
index 3a3b46f1b..cccc0a91b 100644
--- a/src/Modules/LocalRecordsModule/Interfaces/Database/ILocalRecordRepository.cs
+++ b/src/Modules/LocalRecordsModule/Interfaces/Database/ILocalRecordRepository.cs
@@ -6,13 +6,72 @@ namespace EvoSC.Modules.Official.LocalRecordsModule.Interfaces.Database;
public interface ILocalRecordRepository
{
+ ///
+ /// Get all local records from a map by its ID.
+ ///
+ /// ID of the map to get local records from.
+ ///
public Task> GetLocalRecordsOfMapByIdAsync(long mapId);
+
+ ///
+ /// Add a new local record, or update it if its better than existing one.
+ ///
+ /// Map to add local record to.
+ /// The record to add.
+ ///
public Task AddOrUpdateRecordAsync(IMap map, IPlayerRecord record);
+
+ ///
+ /// Add multiple local records to a map.
+ ///
+ /// Map to add local records to.
+ /// Records to add.
+ ///
public Task AddRecordsAsync(IMap map, IEnumerable records);
+
+ ///
+ /// Recalculate positions of all local records in a map. It will
+ /// also remove local records that does not fit within the configured
+ /// top N local records.
+ ///
+ /// Map to re-calculate local records for.
+ ///
public Task RecalculatePositionsOfMapAsync(IMap map);
+
+ ///
+ /// Get local records from a player.
+ ///
+ /// Player to get local records from.
+ ///
public Task> GetRecordsByPlayerAsync(IPlayer player);
+
+ ///
+ /// Get the local record of a player for a map.
+ ///
+ /// The player to get the local record of.
+ /// The map to get the local record for.
+ ///
public Task GetRecordOfPlayerInMapAsync(IPlayer player, IMap map);
+
+ ///
+ /// Delete a local record for a player in a map.
+ ///
+ /// The player that has the local record.
+ /// The map that contains the local record.
+ ///
public Task DeleteRecordAsync(IPlayer player, IMap map);
+
+ ///
+ /// Delete a local record.
+ ///
+ /// The local record to remove.
+ ///
public Task DeleteRecordAsync(ILocalRecord localRecord);
+
+ ///
+ /// Delete all local records from a map.
+ ///
+ /// The map to clear all local records from.
+ ///
public Task DeleteRecordsAsync(IMap map);
}
diff --git a/src/Modules/LocalRecordsModule/Interfaces/ILocalRecord.cs b/src/Modules/LocalRecordsModule/Interfaces/ILocalRecord.cs
index 1742a30af..69b072655 100644
--- a/src/Modules/LocalRecordsModule/Interfaces/ILocalRecord.cs
+++ b/src/Modules/LocalRecordsModule/Interfaces/ILocalRecord.cs
@@ -5,8 +5,23 @@ namespace EvoSC.Modules.Official.LocalRecordsModule.Interfaces;
public interface ILocalRecord
{
+ ///
+ /// The ID of the record.
+ ///
public long Id { get; }
+
+ ///
+ /// The position of the record in the leaderboard.
+ ///
public int Position { get; }
+
+ ///
+ /// The map the record is set on.
+ ///
public IMap Map { get; }
+
+ ///
+ /// The player record.
+ ///
public IPlayerRecord Record { get; }
}
diff --git a/src/Modules/LocalRecordsModule/Interfaces/Services/ILocalRecordsService.cs b/src/Modules/LocalRecordsModule/Interfaces/Services/ILocalRecordsService.cs
index 347dc895f..1828bc803 100644
--- a/src/Modules/LocalRecordsModule/Interfaces/Services/ILocalRecordsService.cs
+++ b/src/Modules/LocalRecordsModule/Interfaces/Services/ILocalRecordsService.cs
@@ -5,10 +5,36 @@ namespace EvoSC.Modules.Official.LocalRecordsModule.Interfaces.Services;
public interface ILocalRecordsService
{
+ ///
+ /// Get all local records of the current map on the server.
+ ///
+ ///
public Task GetLocalsOfCurrentMapAsync();
+
+ ///
+ /// Show/Update the local records widget to a player.
+ ///
+ ///
+ ///
public Task ShowWidgetAsync(IPlayer player);
+
+ ///
+ /// Show/Update the local records widget to all players.
+ ///
+ ///
public Task ShowWidgetToAllAsync();
+
+ ///
+ /// Update a player's local record for the current map.
+ ///
+ ///
+ ///
public Task UpdatePbAsync(IPlayerRecord record);
+ ///
+ /// Remove all local records on all maps, and add them back based on the
+ /// registered PBs of players.
+ ///
+ ///
public Task ResetLocalRecordsAsync();
}
diff --git a/tests/Modules/LocalRecordsModule.Tests/Controllers/LocalRecordsManialinkControllerTests.cs b/tests/Modules/LocalRecordsModule.Tests/Controllers/LocalRecordsManialinkControllerTests.cs
index 74671d24b..b9c6ee6b6 100644
--- a/tests/Modules/LocalRecordsModule.Tests/Controllers/LocalRecordsManialinkControllerTests.cs
+++ b/tests/Modules/LocalRecordsModule.Tests/Controllers/LocalRecordsManialinkControllerTests.cs
@@ -43,4 +43,14 @@ public async Task Reset_Records_Cancel_Does_Not_Resets_All_Records()
AuditEventBuilder.Verify(m => m.Success(), Times.Never);
AuditEventBuilder.Verify(m => m.Error(), Times.Never);
}
+
+ [Fact]
+ public async Task Reset_Records_Error_Is_Reported()
+ {
+ _localRecordsService.Setup(m => m.ResetLocalRecordsAsync()).Throws();
+
+ await Assert.ThrowsAsync(() => Controller.ConfirmResetAsync(true));
+ _server.Server.Verify(m => m.ErrorMessageAsync(It.IsAny()));
+ AuditEventBuilder.Verify(m => m.Error());
+ }
}
diff --git a/tests/Modules/LocalRecordsModule.Tests/LocalRecordsModuleTests.cs b/tests/Modules/LocalRecordsModule.Tests/LocalRecordsModuleTests.cs
new file mode 100644
index 000000000..076647489
--- /dev/null
+++ b/tests/Modules/LocalRecordsModule.Tests/LocalRecordsModuleTests.cs
@@ -0,0 +1,32 @@
+using EvoSC.Manialinks.Interfaces;
+using EvoSC.Modules.Official.LocalRecordsModule.Interfaces.Services;
+using Moq;
+
+namespace LocalRecordsModule.Tests;
+
+public class LocalRecordsModuleTests
+{
+ [Fact]
+ public async Task Widget_Is_Shown_To_All_On_Enable()
+ {
+ var manialinks = new Mock();
+ var localRecords = new Mock();
+ var module = new EvoSC.Modules.Official.LocalRecordsModule.LocalRecordsModule(manialinks.Object, localRecords.Object);
+
+ await module.EnableAsync();
+
+ localRecords.Verify(m => m.ShowWidgetToAllAsync());
+ }
+
+ [Fact]
+ public async Task Widget_Is_Hidden_On_Disable()
+ {
+ var manialinks = new Mock();
+ var localRecords = new Mock();
+ var module = new EvoSC.Modules.Official.LocalRecordsModule.LocalRecordsModule(manialinks.Object, localRecords.Object);
+
+ await module.DisableAsync();
+
+ manialinks.Verify(m => m.HideManialinkAsync("LocalRecordsModule.LocalRecordsWidget"));
+ }
+}