Having the clear locations endpoint only clear world locations, and adding endpoint to remove all items
This commit is contained in:
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user