Adding update endpoint for location, player, spawnable, and user
This commit is contained in:
@@ -37,4 +37,16 @@ public class LocationControllerTests
|
||||
|
||||
Assert.IsType<NotFoundObjectResult>(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Update_NotFound()
|
||||
{
|
||||
var svc = new Mock<LocationService>(config);
|
||||
svc.Setup(l => l.GetByIdAsync("id")).ReturnsAsync((Location?)null);
|
||||
var controller = new LocationController(svc.Object, new Mock<PlayerService>(config).Object);
|
||||
|
||||
var result = await controller.Update("id", new UpdateLocationRequest());
|
||||
|
||||
Assert.IsType<NotFoundObjectResult>(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,21 @@ public class PlayerControllerTests
|
||||
Assert.IsType<NotFoundObjectResult>(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Update_PlayerNotFound()
|
||||
{
|
||||
var svc = new Mock<PlayerService>(cfg);
|
||||
svc.Setup(p => p.GetByUserIdAsync("u")).ReturnsAsync((Player?)null);
|
||||
var controller = new PlayerController(svc.Object, new Mock<LocationService>(cfg).Object, new Mock<SpawnableService>(cfg).Object, new Mock<ItemService>(cfg).Object)
|
||||
{
|
||||
ControllerContext = ContextWithUser("u")
|
||||
};
|
||||
|
||||
var result = await controller.Update(new UpdatePlayerRequest { Name="n", Climbing=1 });
|
||||
|
||||
Assert.IsType<NotFoundObjectResult>(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task AdminTeleport_PlayerNotFound()
|
||||
{
|
||||
|
||||
@@ -66,4 +66,16 @@ public class SpawnableControllerTests
|
||||
|
||||
Assert.IsType<NotFoundObjectResult>(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Update_NotFound()
|
||||
{
|
||||
var svc = new Mock<SpawnableService>(config);
|
||||
svc.Setup(s => s.GetByIdAsync("id")).ReturnsAsync((Spawnable)null);
|
||||
var controller = new SpawnableController(svc.Object);
|
||||
|
||||
var result = await controller.Update("id", new UpdateSpawnableRequest { Name="n", SpawnRate=1, CollectAction="a" });
|
||||
|
||||
Assert.IsType<NotFoundObjectResult>(result);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,4 +43,22 @@ public class UserControllerTests
|
||||
|
||||
Assert.IsType<NotFoundObjectResult>(result);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateUser_NotFound()
|
||||
{
|
||||
var config = new ConfigurationBuilder()
|
||||
.AddInMemoryCollection(new Dictionary<string,string>
|
||||
{
|
||||
{"MongoDB:ConnectionString","mongodb://localhost"},
|
||||
{"MongoDB:DatabaseName","test"}
|
||||
}).Build();
|
||||
var mockService = new Mock<UserService>(config);
|
||||
mockService.Setup(s => s.GetByUsernameAsync("no")).ReturnsAsync((User)null);
|
||||
var controller = new UserController(mockService.Object);
|
||||
|
||||
var result = await controller.UpdateUser("no", new UpdateUserRequest { Email="e", Role="USER" });
|
||||
|
||||
Assert.IsType<NotFoundObjectResult>(result);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user