Example #1
0
        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));
        }
Example #2
0
        public void RootRegistries()
        {
            // There should be no root registries available at start of test
            Assert.That(NetworkableIdRegistry.AllRootRegistries.Count, Is.EqualTo(0));

            // Create one root registry
            NetworkableIdRegistry.CreateRootRegistry(typeof(DummyClass1));

            // After creating a root registry for a given type, that type should be available
            Assert.That(NetworkableIdRegistry.AllRootRegistries.Count, Is.EqualTo(1));
            Assert.That(NetworkableIdRegistry.GetRootRegistry(typeof(DummyClass1)), Is.Not.Null);

            // Other classes should not yet provide a root registry
            Assert.Throws <KeyNotFoundException>(() => NetworkableIdRegistry.GetRootRegistry(typeof(DummyClass2)));

            // Remove root registry
            Assert.DoesNotThrow(() => NetworkableIdRegistry.DestroyRootRegistry(typeof(DummyClass1)));
        }