Merged interfaces to classes
This commit is contained in:
parent
00d777d985
commit
0de20200f5
@ -1,6 +1,4 @@
|
||||
namespace BackendTests.Controllers;
|
||||
|
||||
public class GameControllerTests
|
||||
{
|
||||
|
||||
}
|
||||
public class GameControllerTests // TODO
|
||||
{ }
|
||||
|
@ -3,7 +3,6 @@ using BackendTests.TestUtils;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NSubstitute;
|
||||
using pacMan.Game;
|
||||
using pacMan.Game.Interfaces;
|
||||
using pacMan.Game.Items;
|
||||
using pacMan.Interfaces;
|
||||
using pacMan.Services;
|
||||
|
@ -1,7 +1,7 @@
|
||||
using BackendTests.TestUtils;
|
||||
using pacMan.Exceptions;
|
||||
using pacMan.Game;
|
||||
using pacMan.Game.Interfaces;
|
||||
using pacMan.Game.Items;
|
||||
using pacMan.Services;
|
||||
using pacMan.Utils;
|
||||
|
||||
|
@ -9,7 +9,7 @@ using pacMan.Utils;
|
||||
|
||||
namespace BackendTests.Services;
|
||||
|
||||
public class WebSocketServiceTests // TODO: Implement
|
||||
public class WebSocketServiceTests
|
||||
{
|
||||
private IWebSocketService _service = null!;
|
||||
|
||||
@ -136,7 +136,7 @@ public class WebSocketServiceTests // TODO: Implement
|
||||
{
|
||||
var player = Players.Create("white");
|
||||
var group = _service.AddPlayer(player);
|
||||
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(group.Players, Has.Count.EqualTo(1));
|
||||
@ -148,11 +148,12 @@ public class WebSocketServiceTests // TODO: Implement
|
||||
[Test]
|
||||
public void AddPlayer_ToFullGroup()
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
for (var i = 0; i < 4; i++)
|
||||
{
|
||||
var player = Players.Create(i.ToString());
|
||||
_service.AddPlayer(player);
|
||||
}
|
||||
|
||||
var player5 = Players.Create("white");
|
||||
|
||||
var group = _service.AddPlayer(player5);
|
||||
|
@ -1,10 +1,9 @@
|
||||
using pacMan.Game;
|
||||
using pacMan.Game.Interfaces;
|
||||
using pacMan.Game.Items;
|
||||
|
||||
namespace BackendTests.TestUtils;
|
||||
|
||||
public class Players
|
||||
internal static class Players
|
||||
{
|
||||
internal static IPlayer Create(string colour) =>
|
||||
new Player
|
||||
|
@ -51,13 +51,19 @@ public class ExtensionsTests
|
||||
[Test]
|
||||
public void GetString_NegativeLength()
|
||||
{
|
||||
Assert.Throws(typeof(ArgumentOutOfRangeException), () => _bytes.GetString(-1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => _bytes.GetString(-1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetString_LengthGreaterThanByteArrayLength()
|
||||
{
|
||||
Assert.Throws(typeof(ArgumentOutOfRangeException), () => _bytes.GetString(_bytes.Length + 1));
|
||||
Assert.Throws<ArgumentOutOfRangeException>(() => _bytes.GetString(_bytes.Length + 1));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GetString_LengthShorterThanByteArrayLength()
|
||||
{
|
||||
Assert.That(_bytes.GetString(_bytes.Length / 2), Is.EqualTo("Hello "));
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -1,9 +0,0 @@
|
||||
using pacMan.Game.Items;
|
||||
|
||||
namespace pacMan.Game.Interfaces;
|
||||
|
||||
public interface IBox : IEnumerable<IPellet>
|
||||
{
|
||||
int CountNormal { get; }
|
||||
void Add(Pellet pellet);
|
||||
}
|
@ -1,6 +0,0 @@
|
||||
namespace pacMan.Game.Interfaces;
|
||||
|
||||
public interface IPellet
|
||||
{
|
||||
bool IsPowerPellet { get; init; }
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
using pacMan.Game.Items;
|
||||
|
||||
namespace pacMan.Game.Interfaces;
|
||||
|
||||
public interface IPlayer
|
||||
{
|
||||
string Name { get; init; }
|
||||
Character PacMan { get; init; }
|
||||
string Colour { get; init; }
|
||||
Box Box { get; init; }
|
||||
State State { get; set; }
|
||||
}
|
||||
|
||||
public enum State
|
||||
{
|
||||
WaitingForPlayers,
|
||||
Ready,
|
||||
InGame
|
||||
}
|
@ -1,5 +1,3 @@
|
||||
using pacMan.Game.Interfaces;
|
||||
|
||||
namespace pacMan.Game.Items;
|
||||
|
||||
public class Box : IEquatable<Box>
|
||||
|
@ -1,7 +1,10 @@
|
||||
using pacMan.Game.Interfaces;
|
||||
|
||||
namespace pacMan.Game.Items;
|
||||
|
||||
public interface IPellet
|
||||
{
|
||||
bool IsPowerPellet { get; init; }
|
||||
}
|
||||
|
||||
public class Pellet : IPellet, IEquatable<Pellet>
|
||||
{
|
||||
public bool Equals(Pellet? other)
|
||||
|
@ -1,7 +1,21 @@
|
||||
using pacMan.Game.Interfaces;
|
||||
|
||||
namespace pacMan.Game.Items;
|
||||
|
||||
public interface IPlayer
|
||||
{
|
||||
string Name { get; init; }
|
||||
Character PacMan { get; init; }
|
||||
string Colour { get; init; }
|
||||
Box Box { get; init; }
|
||||
State State { get; set; }
|
||||
}
|
||||
|
||||
public enum State
|
||||
{
|
||||
WaitingForPlayers,
|
||||
Ready,
|
||||
InGame
|
||||
}
|
||||
|
||||
public class Player : IPlayer, IEquatable<Player>
|
||||
{
|
||||
public bool Equals(Player? other)
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Net.WebSockets;
|
||||
using pacMan.Game.Interfaces;
|
||||
using pacMan.Game.Items;
|
||||
using pacMan.Services;
|
||||
|
||||
namespace pacMan.Interfaces;
|
||||
|
@ -1,7 +1,6 @@
|
||||
using System.Text.Json;
|
||||
using Microsoft.CSharp.RuntimeBinder;
|
||||
using pacMan.Game;
|
||||
using pacMan.Game.Interfaces;
|
||||
using pacMan.Game.Items;
|
||||
using pacMan.Interfaces;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System.Collections;
|
||||
using pacMan.Exceptions;
|
||||
using pacMan.Game;
|
||||
using pacMan.Game.Interfaces;
|
||||
using pacMan.Game.Items;
|
||||
|
||||
namespace pacMan.Services;
|
||||
|
||||
@ -10,7 +10,7 @@ public class GameGroup : IEnumerable<IPlayer>
|
||||
private readonly Random _random = new();
|
||||
public List<IPlayer> Players { get; } = new();
|
||||
|
||||
public IPlayer RandomPlayer => Players[_random.Next(Players.Count)];
|
||||
public IPlayer RandomPlayer => Players[_random.Next(Count)];
|
||||
public int Count => Players.Count;
|
||||
|
||||
public IEnumerator<IPlayer> GetEnumerator() => Players.GetEnumerator();
|
||||
|
@ -1,5 +1,5 @@
|
||||
using System.Net.WebSockets;
|
||||
using pacMan.Game.Interfaces;
|
||||
using pacMan.Game.Items;
|
||||
using pacMan.Interfaces;
|
||||
using pacMan.Utils;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user