public void TearDown() { // Unregister Photon serializer/deserializer callbacks for the types PhotonRegisterSerializers registerSerializers = new PhotonRegisterSerializers(); registerSerializers.DeregisterSerializer(typeof(NullMembers)); registerSerializers.DeregisterSerializer(typeof(ConcreteChildById)); registerSerializers.DeregisterSerializer(typeof(AbstractBaseById)); registerSerializers.DeregisterSerializer(typeof(ConcreteChildByValue)); registerSerializers.DeregisterSerializer(typeof(AbstractBaseByValue)); // Deregister types & destroy type registries NetworkableId <Type> .Remove(typeof(NullMembers)); NetworkableId <Type> .Remove(typeof(AbstractBaseById)); NetworkableId <Type> .Remove(typeof(ConcreteChildById)); NetworkableId <AbstractBaseById> .Destroy(); NetworkableId <ConcreteChildById> .Destroy(); NetworkableIdRegistry.DestroyRootRegistry(typeof(AbstractBaseById)); NetworkableId <Type> .Remove(typeof(AbstractBaseByValue)); NetworkableId <Type> .Remove(typeof(ConcreteChildByValue)); NetworkableId <Type> .Destroy(); NetworkableIdRegistry.DestroyRootRegistry(typeof(Type)); }
public void TestSerializationByIdBaseType() { ConcreteChildById concreteObj = new ConcreteChildById(12345678, 87654321); NetworkableId <ConcreteChildById> .Add(concreteObj); byte[] buffer = Protocol.Serialize((AbstractBaseById)concreteObj); ConcreteChildById concreteObj2 = (ConcreteChildById)Protocol.Deserialize(buffer); Assert.That(concreteObj2, Is.EqualTo(concreteObj)); NetworkableId <ConcreteChildById> .Remove(concreteObj); }