Having the clear locations endpoint only clear world locations, and adding endpoint to remove all items

This commit is contained in:
hz
2025-08-21 00:28:45 -05:00
parent 1e4b8463ee
commit b7c221d765
7 changed files with 194 additions and 1 deletions
+34 -1
View File
@@ -3,6 +3,7 @@ using GameAuthApi.Services;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;
using GameAuthApi.Models;
public class AdminControllerTests
{
@@ -10,7 +11,7 @@ public class AdminControllerTests
public async Task GetStatus_ReturnsOk()
{
var expected = new Dictionary<string, string> { { "status", "ok" } };
var mockService = new Mock<AdminService>();
var mockService = new Mock<AdminService>((LocationService)null, (ItemService)null, (PlayerService)null);
mockService.Setup(s => s.GetStatusAsync()).ReturnsAsync(expected);
var controller = new AdminController(mockService.Object);
@@ -19,5 +20,37 @@ public class AdminControllerTests
var ok = Assert.IsType<OkObjectResult>(result);
Assert.Equal(expected, ok.Value);
}
[Fact]
public async Task ResetLocations_ReturnsOk()
{
var newLoc = new Location { LocationType = "World", X = 0, Y = 0, Z = 0 };
var mockService = new Mock<AdminService>((LocationService)null, (ItemService)null, (PlayerService)null);
mockService.Setup(s => s.ResetLocationsAsync()).ReturnsAsync(newLoc);
var controller = new AdminController(mockService.Object);
var result = await controller.ResetLocations();
var ok = Assert.IsType<OkObjectResult>(result);
var origin = Assert.IsType<Location>(ok.Value);
Assert.Equal("World", origin.LocationType);
Assert.Equal(0, origin.X);
Assert.Equal(0, origin.Y);
Assert.Equal(0, origin.Z);
}
[Fact]
public async Task ClearItems_ReturnsOk()
{
var mockService = new Mock<AdminService>((LocationService)null, (ItemService)null, (PlayerService)null);
mockService.Setup(s => s.ClearItemsAsync()).Returns(Task.CompletedTask).Verifiable();
var controller = new AdminController(mockService.Object);
var result = await controller.ClearItems();
var ok = Assert.IsType<OkObjectResult>(result);
Assert.Equal("All items cleared.", ok.Value);
mockService.Verify();
}
}