Separated WebSocketService to another service
This commit is contained in:
@ -6,7 +6,6 @@ using Microsoft.Extensions.Logging;
|
||||
using NSubstitute;
|
||||
using pacMan.Controllers;
|
||||
using pacMan.Game;
|
||||
using pacMan.Interfaces;
|
||||
using pacMan.Services;
|
||||
using pacMan.Utils;
|
||||
|
||||
@ -16,16 +15,16 @@ public class GameControllerTests
|
||||
{
|
||||
private IActionService _actionService = null!;
|
||||
private GameController _controller = null!;
|
||||
private IWebSocketService _webSocketService = null!;
|
||||
private GameService _gameService = null!;
|
||||
|
||||
[SetUp]
|
||||
public void Setup()
|
||||
{
|
||||
_webSocketService = Substitute.For<WebSocketService>(Substitute.For<ILogger<WebSocketService>>());
|
||||
_gameService = Substitute.For<GameService>(Substitute.For<ILogger<GameService>>());
|
||||
_actionService = Substitute.For<ActionService>(
|
||||
Substitute.For<ILogger<ActionService>>(), _webSocketService
|
||||
Substitute.For<ILogger<ActionService>>(), _gameService
|
||||
);
|
||||
_controller = new GameController(Substitute.For<ILogger<GameController>>(), _webSocketService, _actionService);
|
||||
_controller = new GameController(Substitute.For<ILogger<GameController>>(), _gameService, _actionService);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -42,18 +41,14 @@ public class GameControllerTests
|
||||
var result = runMethod!.Invoke(_controller, new object[] { wssResult, data });
|
||||
|
||||
if (result is ArraySegment<byte> resultSegment)
|
||||
{
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(resultSegment, Has.Count.EqualTo(data.Length));
|
||||
Assert.That(Encoding.UTF8.GetString(resultSegment.ToArray()), Is.EqualTo(data.GetString(data.Length)));
|
||||
});
|
||||
// TODO not working, works like a normal method call
|
||||
// _actionService.ReceivedWithAnyArgs().DoAction(default!);
|
||||
}
|
||||
// TODO not working, works like a normal method call
|
||||
// _actionService.ReceivedWithAnyArgs().DoAction(default!);
|
||||
else
|
||||
{
|
||||
Assert.Fail("Result is not an ArraySegment<byte>");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user