コード例 #1
0
        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
ファイル: Scene05ViewModel.cs プロジェクト: brogowski/nebula
 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);
        }
コード例 #7
0
 public void CanSerializeMovePacket()
 {
     Check.That(_serializer.Serialize(_packet))
     .IsEqualTo(_packet.Id.ToString("N"));
 }