Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
snixtho committed Aug 21, 2024
1 parent c8fb677 commit 6089b54
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions tests/EvoSC.Common.Tests/Services/MapServiceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
using EvoSC.Common.Models.Maps;
using EvoSC.Common.Services;
using EvoSC.Testing;
using GbxRemoteNet;
using GbxRemoteNet.Interfaces;
using GbxRemoteNet.Structs;
using GbxRemoteNet.XmlRpc.ExtraTypes;
using Microsoft.Extensions.Logging;
using Moq;
using Xunit;
Expand Down Expand Up @@ -370,6 +372,7 @@ public async Task Add_Current_Map_List_Adds_Maplist()
{
Name = "snippens dream",
Author = "0efeba8a-9cda-49fa-ab25-35f1d9218c95",
AuthorNickname = "snippen",
AuthorTime = 1337,
BronzeTime = 1337,
CopperPrice = 1337,
Expand All @@ -388,10 +391,32 @@ public async Task Add_Current_Map_List_Adds_Maplist()
UpdatedAt = new DateTime(),
LastVisit = new DateTime()
};

_server.Remote.Setup(r => r.GetMapListAsync(It.IsAny<int>(), It.IsAny<int>()))
.Returns(Task.FromResult(new[] { tmMapInfo }));
_playerService.Setup(p => p.GetOrCreatePlayerAsync(It.IsAny<string>()))
_server.Remote.Setup(r => r.MultiCallAsync(It.IsAny<MultiCall>()))
.ReturnsAsync([
new GbxDynamicObject()
{
{ "UId", tmMapInfo.UId },
{ "Name", tmMapInfo.Name },
{ "FileName", tmMapInfo.FileName },
{ "Author", tmMapInfo.Author },
{ "AuthorNickname", tmMapInfo.AuthorNickname },
{ "Environnement", tmMapInfo.Environnement },
{ "Mood", tmMapInfo.Mood },
{ "BronzeTime", tmMapInfo.BronzeTime },
{ "SilverTime", tmMapInfo.SilverTime },
{ "GoldTime", tmMapInfo.GoldTime },
{ "AuthorTime", tmMapInfo.AuthorTime },
{ "CopperPrice", tmMapInfo.CopperPrice },
{ "LapRace", tmMapInfo.LapRace },
{ "NbLaps", tmMapInfo.NbLaps },
{ "NbCheckpoints", tmMapInfo.NbCheckpoints },
{ "MapType", tmMapInfo.MapType },
{ "MapStyle", tmMapInfo.MapStyle }
}
]);
_playerService.Setup(p => p.GetOrCreatePlayerAsync(It.IsAny<string>(), "snippen"))
.Returns(Task.FromResult((IPlayer)player));

await _mapService.AddCurrentMapListAsync();
Expand All @@ -407,6 +432,7 @@ public async Task Get_Or_Add_Current_Map_Returns_Current_Map()
{
Name = "snippens track",
Author = "0efeba8a-9cda-49fa-ab25-35f1d9218c95",
AuthorNickname = "snippen",
AuthorTime = 1337,
BronzeTime = 1337,
CopperPrice = 1337,
Expand Down Expand Up @@ -452,7 +478,7 @@ public async Task Get_Or_Add_Current_Map_Returns_Current_Map()
.Returns(Task.FromResult((IMap?)null));
_mapRepository.Setup(m => m.AddMapAsync(It.IsAny<MapMetadata>(), It.IsAny<IPlayer>(), It.IsAny<string>()))
.Returns(Task.FromResult((IMap)map));
_playerService.Setup(p => p.GetOrCreatePlayerAsync(It.IsAny<string>()))
_playerService.Setup(p => p.GetOrCreatePlayerAsync(It.IsAny<string>(), "snippen"))
.Returns(Task.FromResult((IPlayer)player));

var retrievedMap = await _mapService.GetOrAddCurrentMapAsync();
Expand Down

0 comments on commit 6089b54

Please sign in to comment.