public void CanSerializeSpawnPacket() { _mockGuidSerializer.Serialize(_packet.Id).Returns("A"); _mockVectorSerializer.Serialize(_packet.Position).Returns("B"); _mockQuaternionSerializer.Serialize(_packet.Rotation).Returns("C"); Check.That(_serializer.Serialize(_packet)).IsEqualTo( string.Format("A{0}B{0}C{0}Cat", Environment.NewLine)); }
protected override string[] SerializePacketToFragments(MovePacket packet) { return(new[] { _guidSerializer.Serialize(packet.Id), _vectorSerializer.Serialize(packet.Move), _quaternionSerializer.Serialize(packet.Rotation), packet.Duration.ToString(_floatFormat) }); }
public void Setup() { _mockPacket = new MockPacket(); _packetHeader = typeof(MockPacket).AssemblyQualifiedName; _serializatedMockPacket = "Dummy"; _mockConverter = Substitute.For <IPacketConverter <MockPacket> >(); _mockConverter.Serialize(_mockPacket).Returns(_serializatedMockPacket); _mockConverter.Deserialize(_serializatedMockPacket).Returns(_mockPacket); _serializer = new PacketSerializer(); }
protected override string[] SerializePacketToFragments(SpawnPacket packet) { return(new[] { _guidSerializer.Serialize(packet.Id), _vectorSerializer.Serialize(packet.Position), _quaternionSerializer.Serialize(packet.Rotation), packet.Type }); }
public void ConnectAsClient() { _networking.ConnectAsClient(AddressPort); _updateAction = UpdateClient; _spawnClickAction = () => { var packet = new SpawnPacket(Guid.NewGuid(), new Vector3(0, 5), new Quaternion(), "X"); var serializedPacket = _serializer.Serialize(packet); _networking.SendOnlineMessage(serializedPacket); }; }
public void WhenTypeIsSupported_SerializationIsSuccessful() { _serializer.Serializers.Add(typeof(MockPacket), packet => _mockConverter.Serialize((MockPacket)packet)); Check.That(_serializer.Serialize(_mockPacket)).IsEqualTo(_packetHeader + "|" + _serializatedMockPacket); }
public void CanSerializeMovePacket() { Check.That(_serializer.Serialize(_packet)) .IsEqualTo(_packet.Id.ToString("N")); }