Adding endpoint to create an inventory location
This commit is contained in:
@@ -45,6 +45,32 @@ public class LocationController : ControllerBase
|
|||||||
return Ok(newLoc);
|
return Ok(newLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HttpPost("inventory")]
|
||||||
|
[Authorize(Roles = "SUPER")]
|
||||||
|
public async Task<IActionResult> CreateInventory()
|
||||||
|
{
|
||||||
|
var inventoryLocation = new Location
|
||||||
|
{
|
||||||
|
LocationType = "Inventory",
|
||||||
|
X = null,
|
||||||
|
Y = null,
|
||||||
|
Z = null,
|
||||||
|
N = null,
|
||||||
|
NE = null,
|
||||||
|
E = null,
|
||||||
|
SE = null,
|
||||||
|
S = null,
|
||||||
|
SW = null,
|
||||||
|
W = null,
|
||||||
|
NW = null,
|
||||||
|
Players = new List<string>()
|
||||||
|
};
|
||||||
|
|
||||||
|
await _locationService.CreateAsync(inventoryLocation);
|
||||||
|
|
||||||
|
return Ok(inventoryLocation);
|
||||||
|
}
|
||||||
|
|
||||||
[HttpPut("{id}")]
|
[HttpPut("{id}")]
|
||||||
[Authorize(Roles = "SUPER")]
|
[Authorize(Roles = "SUPER")]
|
||||||
public async Task<IActionResult> Update(string id, [FromBody] UpdateLocationRequest req)
|
public async Task<IActionResult> Update(string id, [FromBody] UpdateLocationRequest req)
|
||||||
|
|||||||
@@ -26,6 +26,19 @@ public class LocationControllerTests
|
|||||||
mockLoc.Verify();
|
mockLoc.Verify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public async Task CreateInventory_ReturnsOk()
|
||||||
|
{
|
||||||
|
var mockLoc = new Mock<LocationService>(config);
|
||||||
|
mockLoc.Setup(l => l.CreateAsync(It.IsAny<Location>())).Returns(Task.CompletedTask).Verifiable();
|
||||||
|
var controller = new LocationController(mockLoc.Object, new Mock<PlayerService>(config).Object);
|
||||||
|
|
||||||
|
var result = await controller.CreateInventory();
|
||||||
|
|
||||||
|
Assert.IsType<OkObjectResult>(result);
|
||||||
|
mockLoc.Verify();
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task GetById_NotFound()
|
public async Task GetById_NotFound()
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user