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));
        }
示例#2
0
 protected override string[] SerializePacketToFragments(MovePacket packet)
 {
     return(new[]
     {
         _guidSerializer.Serialize(packet.Id),
         _vectorSerializer.Serialize(packet.Move),
         _quaternionSerializer.Serialize(packet.Rotation),
         packet.Duration.ToString(_floatFormat)
     });
 }
示例#3
0
 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();
 }
示例#4
0
 protected override string[] SerializePacketToFragments(SpawnPacket packet)
 {
     return(new[]
     {
         _guidSerializer.Serialize(packet.Id),
         _vectorSerializer.Serialize(packet.Position),
         _quaternionSerializer.Serialize(packet.Rotation),
         packet.Type
     });
 }
示例#5
0
 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);
     };
 }
示例#6
0
        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"));
 }