public Client(TcpClient tcpClient, CancellationTokenSource tokenSource) { _game = null; _tcpClient = tcpClient; _tokenSource = tokenSource; _stream = _tcpClient.GetStream(); _packageFactory = new ClientPackageFactory(); ClientsCount++; }
public void GetRoomPackageDeserialization2Test() { GetRoomPackage expected = new GetRoomPackage(); var buffer = expected.ToByteArray(); GetRoomPackage actual = null; using (var stream = new MemoryStream(buffer)) { ClientPackageFactory factory = new ClientPackageFactory(); actual = (GetRoomPackage)factory.GetNextPackage(stream); } Assert.NotNull(actual); Assert.AreEqual(ClientPackageType.GetRoom, actual.Type); }
public void SetUp() { _factory = new ClientPackageFactory(); _setTargetsPackage = new SetTargetsPackage { Units = new Unit[5] }; for (int i = 0; i < _setTargetsPackage.Units.Length; i++) { var unit = new Unit { Id = i + 1, Position = new Position(1 * i, 5 * i), State = States.Move, TargetPosition = new Position(1 * i, 5 * i) }; _setTargetsPackage.Units[i] = unit; } }